Regex.replace
Regex.replace
Function
Replace text using the current regular expression.
Syntax
regex(pattern, flags).replace(text, to)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| text | Any | No | '' | The text to process. |
| to | Any | No | '' | The replaced content. |
Return value
| Type | Description |
|---|---|
| String | Returns the replaced string. |
Example
rule = regex('[0-9]+', 'g') result = rule.replace('a1 b22', '#') // Output: a# b# print result
Notes
- Replaces all matches if flags contains g; otherwise only replaces the first match.