Regex regular expression
Regex regular expression
Function
Regex objects are created by regex(pattern, flags) and support test, match, replace and to_string. String prototype search, match, replace can also receive Regex parameters.
API List
| API | Description |
|---|---|
| Regex.test | Determine whether the text matches the current regular expression. |
| Regex.match | Returns all matching fragments in the text. |
| Regex.replace | Replace text using the current regular expression. |
| Regex.to_string | Returns the script text form of the regular expression. |
Examples
rule = regex('BT', 'i') result = rule.test('bt lang') // Output: true print result
Notes
- Supported flags include i, m, s; the global replacement of replace additionally reads the g flag.