working on documentation and more API functions
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
:sig
|
||||
String regex_replace(String pattern, String replacement, String subject)
|
||||
String regex_replace(String pattern, String replacement, String subject, String flags)
|
||||
|
||||
:params
|
||||
pattern : PCRE2 regular expression pattern
|
||||
replacement : replacement string
|
||||
subject : string where replacements should happen
|
||||
flags : optional regex flags
|
||||
return value : a new string with all matches replaced
|
||||
|
||||
:see
|
||||
>regex
|
||||
regex_match
|
||||
regex_search
|
||||
regex_search_all
|
||||
regex_split
|
||||
replace
|
||||
|
||||
:content
|
||||
Replaces every match of `pattern` in `subject` and returns the transformed string.
|
||||
|
||||
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.
|
||||
Reference in New Issue
Block a user