Regex metacharacters
Regex metacharacters
Function
Explain the common usage of regular metacharacters such as ^, $, ., | and so on.
Syntax
regex(pattern, flags)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| pattern | String | No | '' | Regular body containing metacharacters. |
| flags | String | No | '' | Regular flags. |
Return value
| Type | Description |
|---|---|
| Regex | Returns a Regex object. |
Example
rule = regex('^(BT|Rust)$', '') result = rule.test('Rust') // Output: true print result
Notes
- When it is necessary to match the metacharacter itself, escape characters should be written in pattern according to string rules.