class Regex
pub class Regex
A compiled regular expression.
Methods
pub static fn new(pattern: string): Regex throws RegexError
Compiles pattern.
Errors
Throws RegexError { offset, detail } where the pattern is not RE2's syntax.
pub fn pattern(): string
Returns the pattern as given.
pub fn groupCount(): int
Returns how many capture groups the pattern has, the whole match not counted.
pub fn groupNames(): Map<string, int>
Returns the names of the named groups with their indices.
pub fn isMatch(s: StringView): bool
Returns whether the text holds a match.
pub fn find(s: StringView): ?Match
Returns the leftmost match, with its groups; null where there is none.
pub fn findFrom(s: StringView, from: int): ?Match
Returns the leftmost match at or after the byte offset from; null where there is none
or from lies past the end of the text.
pub fn findAll(s: StringView): Matches
Returns every match in turn, left to right, none overlapping; an empty match right after a match is skipped.
pub fn replace(s: StringView, template: string): string
Returns the text with its first match replaced by the template: $1 and ${name} are the groups, $0 the
whole, $$ a $; an unmatched group is empty.
pub fn replaceAll(s: StringView, template: string): string
Returns the text with every match replaced by the template, as replace expands it.
pub fn split(s: StringView): string[]
Returns the pieces of the text between its matches. An empty text is one empty piece; an empty match at the very start adds no empty piece before it.