Regex
@Serializable { simple=true }
const class Regex : Obj
Regex represents a regular expression.
Compile a regular expression pattern string
Default value is Regex("")
Return the regular expression pattern string
Make a Regex that matches the given string exactly
Split the specified string around matches of this pattern
Equality is based on pattern string and flags
Return flags string
Make a Regex which will match a glob pattern
Return a RegexMatcher instance to use for matching operations against the specified string
Convenience for matcher(s).matches
Return toStr.hash
const static Regex : defVal
Default value is Regex("").
virtual Bool equals(Obj? obj)
Equality is based on pattern string and flags.
Str flags()
Return flags string
static new fromStr(Str pattern, Str flags)
Compile a regular expression pattern string. Flags is a string of ASCII chars. In JavaScript the flags are passed directly to RegExp. In Java the flags are matched against known constants or ignored. The following cross-platform flags are supported:
i: case insensitivem: multi-line support for start/end matchings: dot all to allow "." to match newlines
static Regex glob(Str pattern)
Make a Regex which will match a glob pattern:
- "?": match one unknown char (maps to "." in regex)
- "*": match zero or more unknown char (maps to ".*" in regex)
- any other character is matched exactly
virtual Int hash()
Return toStr.hash.
RegexMatcher matcher(Str s)
Return a RegexMatcher instance to use for matching operations against the specified string.
Bool matches(Str s)
Convenience for matcher(s).matches.
static Regex quote(Str str)
Make a Regex that matches the given string exactly. All non-alpha numeric characters are escaped.
Str[] split(Str s, Int limit)
Split the specified string around matches of this pattern. The limit parameter specifies how many times to apply the pattern:
- If
limitis greater than zero, the pattern is applied at mostlimit-1times and any remaining input will be returned as the list's last item. - If
limitis less than zero, then the pattern is matched as many times as possible. - If
limitis zero, then the pattern is matched as many times as possible, but trailing empty strings are discarded.
virtual Str toStr()
Return the regular expression pattern string.