Regex
sealed class Regeximport Regex from Wax;A compiled regular expression created with Wax regex(...) syntax. Literal patterns are checked
at compile time; dynamic patterns can report RegexError. Matching works in Unicode code
points, while public indices, lengths, and starting positions are UTF-8 byte offsets. Searches
find matches at or after the start rather than implicitly anchoring the entire input.
Non-overlapping iteration advances after empty matches to ensure progress.
import Regex from Wax;
api fn Main() : int32 {
Regex digits = regex(/[0-9]+/);
var match = digits.Match("item 42");
return match != null ? match!.length : 0;
}
Inherits from object. Follow these links for inherited members.
Members
optionsfield
public readonly RegexOptions optionsThe flags used to compile this expression.
patternfield
public readonly string patternThe original expression text.
IsMatchmethod
public fn IsMatch(string text) : boolReturns whether the expression finds a match anywhere in the input.
IsMatchAtmethod
public fn IsMatchAt(string text, int32 startAt) : boolSearches at or after byte offset startAt. Negative offsets start at zero; offsets inside a
code point advance to the next boundary, and offsets past the input clamp to the end.
Matchmethod
public fn Match(string text) : Match?Returns the first match, or null if no match exists.
MatchAtmethod
public fn MatchAt(string text, int32 startAt) : Match?Returns the first match at or after the starting byte offset, or null. The offset follows
the clamping and boundary rules of IsMatchAt.
Countmethod
public fn Count(string text) : int32Counts non-overlapping matches, including empty matches. An empty match advances by one code point before searching again.
Matchesmethod
public fn Matches(string text) : MatchIteratorReturns an iterator over non-overlapping matches from the start of the input.
MatchesAtmethod
public fn MatchesAt(string text, int32 startAt) : MatchIteratorReturns a non-overlapping match iterator starting at the supplied byte offset, using the
same starting-position rules as IsMatchAt.
Escapemethod
public static fn Escape(string text) : stringPrefixes regex metacharacters with a backslash for literal matching. Does not additionally escape whitespace or #-comments for FreeSpacing mode.
Replacemethod
public fn Replace(string text, string replacement) : stringReplaces non-overlapping matches. Replacement syntax supports $$ for a dollar sign, $&
for the full match, $1–$99 for captures, and $<name> for named captures. Unmatched
captures contribute empty text.
ReplaceCountmethod
public fn ReplaceCount(string text, string replacement, int32 count) : stringUses the same substitutions as Replace, stopping after at most a positive count matches.
A nonpositive count means no limit.
ReplaceWithmethod
public fn ReplaceWith(string text, fn<(Match) : string> evaluator) : stringReplaces each non-overlapping match with the string returned by the evaluator. Evaluator output is literal text, without replacement-template expansion.
Splitmethod
public fn Split(string text) : string[]Splits around non-overlapping matches, preserving empty segments. Capture groups are not inserted into the result.
SplitCountmethod
public fn SplitCount(string text, int32 count) : string[]Splits into at most a positive count segments, retaining the remainder as the last
segment. A nonpositive count means no limit.