std/text/regex
std/regex — Pattern / Matcher API over the Rust regex crate.
Compile a Pattern once, then run whole-string tests (matches),
single-scan tests (find), or substitutions (replaceAll /replaceFirst / split). For capture groups and iteration over
every match in one input, derive a Matcher and advance it withfind(), reading the current capture through the group*
accessors. The crate uses linear-time RE2-style matching, so it has
no backreferences or lookaround and cannot catastrophically
backtrack.
A Pattern owns a registry slot; it is Closeable so a
try-resources binding releases the compiled regex deterministically.
C class Pattern
A compiled regex held by registry handle. Compile once, then run
whole-string (matches) or scanning (find) queries, derive a
per-input Matcher, or rewrite via replaceAll / replaceFirst.
Constructors
| Type | Method and description |
|---|---|
| constructor(regex : string) Compiles regex (Rust regex-crate syntax) into this pattern. |
Method detail
#constructor
Compiles regex (Rust regex-crate syntax) into this pattern.
regex the regular expression source to compileMethods
Method detail
#matcher
#matches
#find
#replaceAll
#replaceFirst
#split
#pattern
#close
C class Matcher
A stateful cursor bound to one input string: find() advances to
the next match, the group* accessors read the current capture,
and reset() rewinds to the start.
Methods
| Type | Method and description |
|---|---|
| find(self) : bool |
| matches(self) : bool |
| group(self) : string |
| groupAt(self, index : i32) : string |
| groupCount(self) : i32 |
| start(self) : i32 |
| end(self) : i32 |
| reset(self) : void |
| replaceAll(self, replacement : string) : string |