regex
Since 1.4.0Constants
Pattern : map =
17 elements
{
UNIX_LINES=1,
CASE_INSENSITIVE=2,
I=2,
COMMENTS=4,
MULTILINE=8,
M=8,
LITERAL=16,
S=32,
DOTALL=32,
UNICODE_CASE=64,
CANON_EQ=128,
UNICODE_CHARACTER_CLASS=256,
U=256,
quote=def(s) { return string },
matches=def(str,pattern) { return boolean },
split=def(str,pattern,limit = 0) { return array },
compile=def(pattern,flags = 0) { return PatternValue }
}
Functions
regex(pattern, flags = 0) — creates pattern and returns PatternValue
Types
PatternValue
Functions
flags() — returns pattern flags
pattern() — returns pattern as string
matcher(input) — returns MatcherValue
matches(input) — checks if input matches the pattern
split(input, limit = 0) — splits input around matches of this pattern
replaceCallback(input, callback) — replaces input with the result of the given callback
use regex
in = "dog cat"
pattern = regex("(\w+)\s(\w+)", Pattern.I)
println pattern.replaceCallback(in, def(m) = m.group(2) + "" + m.group(1))
use regex
in = "dog cat"
pattern = regex("(\w+)\s(\w+)", Pattern.I)
println pattern.replaceCallback(in, def(m) = m.group(2) + "" + m.group(1))
MatcherValue
Functions
start(group = ...) — returns the start index of matched subsequence
end(group = ...) — returns the offset after last character of matched subsequence
find(start = 0) — resets this matcher and attempts to find the next matched subsequence
group(group = 0) — returns matched group
pattern() — returns the pattern
region(start, end) — sets the limits of this matcher's region
replaceFirst(replacement) — replaces first matched subsequence with the given replacement string
replaceAll(replacement) — replaces all matched subsequences with the given replacement string
replaceCallback(callback) — replaces input with the result of the given callback
use regex
in = "dog cat"
pattern = regex("(\w+)\s(\w+)", Pattern.I)
matcher = pattern.matcher(in)
println matcher.replaceCallback(def(m) = m.group(2) + m.group(1))
reset(input = "")
usePattern(patternvalue)
useAnchoringBounds(status)
hasAnchoringBounds()
useTransparentBounds(status)
hasTransparentBounds()
hitEnd()
lookingAt()
matches()
groupCount()
regionStart()
regionEnd()