std/regexp
On this page
Index
- type
Regex- method
Regex.pattern - method
Regex.is_match - method
Regex.find - method
Regex.find_index - method
Regex.find_all - method
Regex.captures - method
Regex.named - method
Regex.replace_all - method
Regex.replace_all_literal - method
Regex.split
- method
- type
RegexErr- method
RegexErr.display
- method
- fn
compile - fn
must - fn
quote
Types
Regex
struct Regex {}A compiled expression: an immutable compiled value, comparable (not a handle, decision 0112 addendum).
Regex.pattern
fn (r: Regex) pattern() -> StrRegex.is_match
fn (r: Regex) is_match(s: Str) -> BoolRegex.find
fn (r: Regex) find(s: Str) -> Str?The leftmost match.
Regex.find_index
fn (r: Regex) find_index(s: Str) -> (Int, Int)?The byte offsets (start, end) of the leftmost match.
Regex.find_all
fn (r: Regex) find_all(s: Str) -> List[Str]Every match, left to right, not overlapping.
Regex.captures
fn (r: Regex) captures(s: Str) -> List[Str?]?The leftmost match and its groups: element 0 is the whole match, then one per group, None for a group that did not take part.
Regex.named
fn (r: Regex) named(s: Str) -> Map[Str, Str]?The named groups ((?P<name>...)) of the leftmost match that took part.
Regex.replace_all
fn (r: Regex) replace_all(s: Str, repl: Str) -> StrEvery match replaced by repl, in which $1 and ${name} stand for
groups ($$ for a dollar sign).
Regex.replace_all_literal
fn (r: Regex) replace_all_literal(s: Str, repl: Str) -> StrEvery match replaced by repl as written (no $ expansion).
Regex.split
fn (r: Regex) split(s: Str) -> List[Str]s split around the matches.
RegexErr
struct RegexErr {
pattern: Str
msg: Str
}Displays as invalid regexp "(a": missing closing ): ....
RegexErr.display
fn (e: RegexErr) display() -> StrFunctions
compile
fn compile(pattern: Str) -> Regex ! RegexErrmust
fn must(pattern: Str) -> Regexcompile, faulting on a bad pattern (for patterns written in the program).
quote
fn quote(text: Str) -> Strtext with every metacharacter escaped: a pattern matching text literally.
↑ index