cleanup, docs
This commit is contained in:
@@ -10,6 +10,7 @@ flags : optional regex flags
|
||||
return value : a new string with all matches replaced
|
||||
|
||||
:see
|
||||
>string
|
||||
>regex
|
||||
regex_match
|
||||
regex_search
|
||||
@@ -22,16 +23,12 @@ Replaces every match of `pattern` in `subject` and returns the transformed strin
|
||||
|
||||
Example:
|
||||
|
||||
```uce
|
||||
String html = regex_replace(
|
||||
"@([A-Za-z0-9_]+)",
|
||||
"<a href=\"/users/$1\">@$1</a>",
|
||||
"Hello @alice and @bob"
|
||||
);
|
||||
```
|
||||
|
||||
Replacement strings use PCRE2 substitution syntax, including numbered capture references such as `$1` and named references such as `${name}`.
|
||||
|
||||
For simple literal search-and-replace, use `replace()`. Use `regex_replace()` when the match condition needs a pattern, captures, character classes, anchors, or flags.
|
||||
|
||||
Invalid patterns, invalid flags, or invalid substitution syntax raise a request-visible runtime error.
|
||||
|
||||
:example
|
||||
print(regex_replace("docs", "manual", "uce docs"), "\n");
|
||||
|
||||
Reference in New Issue
Block a user