matcher
matcher: (Pattern, string) -> MatcherA matcher of this pattern over input.
Pattern.compile(…)
Pattern.compile(…):matcher(…):pattern()| Method | Returns | Description |
|---|---|---|
matcher(string) | Matcher | A matcher of this pattern over input. |
find(string) | boolean | Alternative to p:matcher(s):find(): a one-call search with no Matcher object. Whether this pattern matches anywhere in input: `p:find… |
split(string) | {string} | (Pattern, string) -> {string}: input split around matches, trailing empty strings removed (a 1-based array). |
split(string, number) | {string} | |
pattern() | string | The source regular expression. |
toString() | string | The source regular expression. |
flags() | number | The flags: those it was compiled with, and those a top-level inline group turned on or off ((?i)a answers CASE_INSENSITIVE; (?i:a) do… |
compile(string) | Pattern | (string) -> Pattern: Compile regex. |
compile(string, number) | Pattern | |
quote(string) | string | A pattern matching s literally: \Q + s + \E, with any \E in s escaped. |
matches(string, string) | boolean | Whether regex matches the whole of input. |
| Field | Type | Description |
|---|---|---|
UNIX_LINES | number | Pattern's flag bit. |
CASE_INSENSITIVE | number | Pattern's flag bit. |
COMMENTS | number | Pattern's flag bit. |
MULTILINE | number | Pattern's flag bit. |
LITERAL | number | Pattern's flag bit. |
DOTALL | number | Pattern's flag bit. |
UNICODE_CASE | number | Pattern's flag bit. |
CANON_EQ | number | Pattern.CANON_EQ's bit. Bento does not implement canonical equivalence: a pattern compiled with it raises. |
UNICODE_CHARACTER_CLASS | number | Pattern's flag bit. |
| Method | Returns | Description |
|---|---|---|
Matcher.pattern | Pattern | The pattern: the very Pattern it was made from (or last given to usePattern). |
PatternClass.compile | Pattern | (string) -> Pattern: Compile regex. |
matchermatcher: (Pattern, string) -> MatcherA matcher of this pattern over input.
findfind: (Pattern, string) -> booleanAlternative to p:matcher(s):find(): a one-call search with no Matcher object. Whether this pattern matches anywhere in input: p:find(s) answers what p:matcher(s):find() answers, without making the matcher, for a filter that only asks whether a line matches (a chat filter, a hidden-item list). For the match's position or groups, use matcher.
splitsplit: ((Pattern, string) -> {string}) & ((Pattern, string, number) -> {string})(Pattern, string) -> {string}: input split around matches, trailing empty strings removed (a 1-based array).
(Pattern, string, number) -> {string}: input split around matches: at most limit pieces when positive, every piece when negative, trailing empty strings removed when 0 (or nil).
patternpattern: (Pattern) -> stringThe source regular expression.
toStringtoString: (Pattern) -> stringThe source regular expression.
flagsflags: (Pattern) -> numberThe flags: those it was compiled with, and those a top-level inline group turned on or off ((?i)a answers CASE_INSENSITIVE; (?i:a) does not).
compilecompile: ((string) -> Pattern) & ((string, number) -> Pattern)(string) -> Pattern: Compile regex.
(string, number) -> Pattern: Compile regex with flags (Pattern.CASE_INSENSITIVE, ... or'ed).
quotequote: (string) -> stringA pattern matching s literally: \Q + s + \E, with any \E in s escaped.
matchesmatches: (string, string) -> booleanWhether regex matches the whole of input.