public final class Pattern extends Object implements Serializable
java.util.regex.Pattern API.
The matching functions take String arguments instead of
the more general Java CharSequence since the latter doesn't
provide UTF-16 decoding.
See the package-level documentation for an overview of how to use this API.
| Modifier and Type | Field and Description |
|---|---|
static int |
CASE_INSENSITIVE
Flag: case insensitive matching.
|
static int |
DISABLE_UNICODE_GROUPS
Flag: Unicode groups (e.g.
|
static int |
DOTALL
Flag: dot (
.) matches all characters, including newline. |
static int |
MULTILINE
Flag: multiline matching:
^ and $ match at
beginning and end of line, not just beginning and end of input. |
| Modifier and Type | Method and Description |
|---|---|
static Pattern |
compile(String regex)
Creates and returns a new
Pattern corresponding to
compiling regex with the default flags (0). |
static Pattern |
compile(String regex,
int flags)
Creates and returns a new
Pattern corresponding to
compiling regex with the default flags (0). |
static Pattern |
compile(String regex,
int flags,
Options options) |
static Pattern |
compile(String regex,
Options options) |
boolean |
find(io.airlift.slice.Slice input) |
static boolean |
find(String regex,
io.airlift.slice.Slice input)
Matches a
Slice against a regular expression (unanchored). |
static boolean |
find(String regex,
io.airlift.slice.Slice input,
Options options) |
int |
flags()
Returns the flags used in the constructor.
|
int |
groupCount()
Returns the number of capturing groups in this matcher's pattern.
|
Matcher |
matcher(io.airlift.slice.Slice input)
Creates a new
Matcher matching the pattern against the input. |
boolean |
matches(io.airlift.slice.Slice input) |
static boolean |
matches(String regex,
io.airlift.slice.Slice input)
Matches a
Slice against a regular expression. |
static boolean |
matches(String regex,
io.airlift.slice.Slice input,
Options options) |
Options |
options()
Returns the options used in the constructor.
|
String |
pattern()
Returns the pattern used in the constructor.
|
static String |
quote(String s)
Returns a literal pattern string for the specified
string.
|
io.airlift.slice.Slice[] |
split(io.airlift.slice.Slice input)
Splits input around instances of the regular expression.
|
io.airlift.slice.Slice[] |
split(io.airlift.slice.Slice input,
int limit)
Splits input around instances of the regular expression.
|
String |
toString() |
public static final int CASE_INSENSITIVE
public static final int DOTALL
.) matches all characters, including newline.public static final int MULTILINE
^ and $ match at
beginning and end of line, not just beginning and end of input.public static final int DISABLE_UNICODE_GROUPS
\p\{Greek\}) will be syntax errors.public int flags()
public Options options()
public String pattern()
public static Pattern compile(String regex)
Pattern corresponding to
compiling regex with the default flags (0).regex - the regular expressionPatternSyntaxException - if the pattern is malformedpublic static Pattern compile(String regex, int flags)
Pattern corresponding to
compiling regex with the default flags (0).regex - the regular expressionflags - bitwise OR of the flag constants CASE_INSENSITIVE,
DOTALL, and MULTILINEPatternSyntaxException - if the regular expression is malformedIllegalArgumentException - if an unknown flag is givenpublic static boolean matches(String regex, io.airlift.slice.Slice input)
Slice against a regular expression.regex - the regular expressioninput - the inputPatternSyntaxException - if the regular expression is malformedpublic boolean matches(io.airlift.slice.Slice input)
public static boolean find(String regex, io.airlift.slice.Slice input)
Slice against a regular expression (unanchored).regex - the regular expressioninput - the inputPatternSyntaxException - if the regular expression is malformedpublic boolean find(io.airlift.slice.Slice input)
public Matcher matcher(io.airlift.slice.Slice input)
Matcher matching the pattern against the input.input - the input Slicepublic io.airlift.slice.Slice[] split(io.airlift.slice.Slice input)
Slices that occur before, between, and after instances
of the regular expression. Empty Slices that would occur at the end
of the array are omitted.input - the input Slice to be splitSlicespublic io.airlift.slice.Slice[] split(io.airlift.slice.Slice input,
int limit)
Slices that occur before, between, and after instances
of the regular expression.
If limit <= 0, there is no limit on the size of the returned array.
If limit == 0, empty Slices that would occur at the end of the array are omitted.
If limit > 0, at most limit Slices are returned. The final Slice contains
the remainder of the input, possibly including additional matches of the pattern.
input - the input Slice to be splitlimit - the limitSlicespublic static String quote(String s)
This method produces a string that can be used to
create a Pattern that would match the string
s as if it were a literal pattern.
s - The string to be literalizedpublic int groupCount()
Copyright © 2016. All Rights Reserved.