type
Regex
src
@Serializable { simple=true }
const class Regex : Obj
Regex represents a regular expression.
constructors
fromStr |
Compile a regular expression pattern string. |
---|
fields
defVal |
Default value is Regex(""). |
---|
methods
equals |
Equality is based on pattern string and flags. |
---|---|
flags |
Return flags string |
glob |
Make a Regex which will match a glob pattern |
hash |
Return |
matcher |
Return a |
matches |
Convenience for |
quote |
Make a Regex that matches the given string exactly. |
split |
Split the specified string around matches of this pattern. |
toStr |
Return the regular expression pattern string. |
Slot Details
defVal
equals
flags
fromStr
src
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
glob
hash
matcher
src
RegexMatcher matcher(Str s)
Return a RegexMatcher
instance to use for matching operations against the specified string.
matches
Convenience for matcher(s).matches
.
quote
split
src
Str[] split(Str s, Int limit := 0)
Split the specified string around matches of this pattern. The limit
parameter specifies how many times to apply the pattern:
- If
limit
is greater than zero, the pattern is applied at mostlimit-1
times and any remaining input will be returned as the list's last item. - If
limit
is less than zero, then the pattern is matched as many times as possible. - If
limit
is zero, then the pattern is matched as many times as possible, but trailing empty strings are discarded.