re
re
Regex builtin namespace.
Runtime support: native and WebAssembly.
Import
use re;
Functions
| Function | Description |
|---|---|
match | Returns whether a regular expression matches the input text. |
find | Returns the first substring matched by a regular expression. |
replace | Replaces all regular-expression matches in a string. |
split | Splits a string on regular-expression matches. |
captures | Returns the capture groups produced by the first regular-expression match. |
Function details
match
fn match(pattern: string, text: string) -> bool
Returns whether a regular expression matches the input text.
find
fn find(pattern: string, text: string) -> string
null
Returns the first substring matched by a regular expression.
replace
fn replace(pattern: string, text: string, replacement: string) -> string
Replaces all regular-expression matches in a string.
split
fn split(pattern: string, text: string) -> array
Splits a string on regular-expression matches.
captures
fn captures(pattern: string, text: string) -> array
Returns the capture groups produced by the first regular-expression match.