Modifier and Type | Field and Description |
---|---|
static Pattern |
ALWAYS
A
Pattern that always matches with match length 0 . |
static Pattern |
ANY_CHAR
A
Pattern that matches any character and only mismatches for an empty string. |
static Pattern |
DEC_INTEGER
A
Pattern object that matches a decimal integer, which starts with a non-zero digit and is followed by 0 or
more digits. |
static Pattern |
DECIMAL
A
Pattern object that matches a decimal number that could start with a decimal point or a digit. |
static Pattern |
EOF
A
Pattern object that matches if the input has no character left. |
static Pattern |
ESCAPED
A
Pattern object that succeeds with match length 2 if there are at least 2 characters in the input
and the first character is '\' . |
static Pattern |
FRACTION
A
Pattern object that matches a decimal point and one or more digits after it. |
static Pattern |
HEX_INTEGER
A
Pattern object that matches a hex integer, which starts with a 0x or 0X , and is followed
by one or more hex digits. |
static Pattern |
INTEGER
A
Pattern object that matches an integer. |
static Pattern |
NEVER
A
Pattern that always returns Pattern.MISMATCH . |
static Pattern |
OCT_INTEGER
A
Pattern object that matches an octal integer that starts with a 0 and is followed by 0 or more
[0 - 7] characters. |
static Pattern |
REGEXP_MODIFIERS
A
Pattern object that matches regular expression modifiers, which is a list of alpha characters. |
static Pattern |
REGEXP_PATTERN
A
Pattern object that matches any regular expression pattern string in the form of /some pattern
here/ . |
static Pattern |
SCIENTIFIC_NOTATION
|
static Pattern |
STRICT_DECIMAL
A
Pattern object that matches a decimal number that has at least one digit before the decimal point. |
static Pattern |
WORD
A
Pattern object that matches a standard english word, which starts with either an underscore or an alpha
character, followed by 0 or more alphanumeric characters. |
Modifier and Type | Method and Description |
---|---|
static Pattern |
among(String chars)
Returns a
Pattern object that matches if the current character in the input is equal to any character in
chars , in which case 1 is returned as match length. |
static Pattern |
and(Pattern... patterns)
Returns a
Pattern that matches if all of patterns matches, in which case, the maximum match length
is returned. |
static Pattern |
atLeast(int min,
CharPredicate predicate)
Returns a
Pattern object that matches if the input starts with min or more characters and all
satisfy predicate . |
static Pattern |
atMost(int max,
CharPredicate predicate)
|
static Pattern |
hasAtLeast(int n)
Returns a
Pattern object that matches if the input has at least n characters left. |
static Pattern |
hasExact(int n)
Returns a
Pattern object that matches if the input has exactly n characters left. |
static Pattern |
isChar(char c)
Returns a
Pattern object that matches if the current character in the input is equal to character c , in which case 1 is returned as match length. |
static Pattern |
isChar(CharPredicate predicate)
Returns a
Pattern object that matches if the current character in the input satisfies predicate , in
which case 1 is returned as match length. |
static Pattern |
lineComment(String begin)
Returns a
Pattern object that matches a line comment started by begin and ended by EOF or
LF (the line feed character). |
static Pattern |
longer(Pattern p1,
Pattern p2)
|
static Pattern |
longest(Pattern... patterns)
Returns a
Pattern that tries all of patterns , and picks the one with the
longest match length. |
static Pattern |
many(CharPredicate predicate)
Returns a
Pattern that matches 0 or more characters satisfying predicate . |
static Pattern |
many(int min,
CharPredicate predicate)
Deprecated.
Use
atLeast(int, CharPredicate) instead. |
static Pattern |
many1(CharPredicate predicate)
Returns a
Pattern that matches 1 or more characters satisfying predicate . |
static Pattern |
not(Pattern pattern) |
static Pattern |
notString(String string)
Returns a
Pattern object that matches if the input has at least 1 character and doesn't match string . |
static Pattern |
notStringCaseInsensitive(String string)
Returns a
Pattern object that matches if the input has at least 1 character and doesn't match string case insensitively. |
static Pattern |
or(Pattern... patterns)
Returns a
Pattern that matches if any of patterns matches, in which case, the first match length is
returned. |
static Pattern |
range(char c1,
char c2)
Returns a
Pattern object that matches if the current character in the input is between character c1
and c2 , in which case 1 is returned as match length. |
static Pattern |
regex(Pattern p)
Adapts a regular expression pattern to a
Pattern . |
static Pattern |
regex(String s)
Adapts a regular expression pattern string to a
Pattern . |
static Pattern |
repeat(int n,
CharPredicate predicate)
Returns a
Pattern object that matches if the input has at least n characters and the first n characters all satisfy predicate . |
static Pattern |
sequence(Pattern... patterns)
Returns a
Pattern object that matches the input against patterns sequentially. |
static Pattern |
shorter(Pattern p1,
Pattern p2)
|
static Pattern |
shortest(Pattern... patterns)
Returns a
Pattern that tries all of patterns , and picks the one with the shortest match length. |
static Pattern |
some(int max,
CharPredicate predicate)
Deprecated.
Use
atMost(int, CharPredicate) instead. |
static Pattern |
some(int min,
int max,
CharPredicate predicate)
Deprecated.
Use
times(int, int, CharPredicate) instead. |
static Pattern |
string(String string)
Returns a
Pattern object that matches string literally. |
static Pattern |
stringCaseInsensitive(String string)
Returns a
Pattern object that matches string case insensitively. |
static Pattern |
times(int min,
int max,
CharPredicate predicate)
Returns a
Pattern that matches at least min and up to max number of characters satisfying
predicate , |
public static final Pattern NEVER
Pattern
that always returns Pattern.MISMATCH
.public static final Pattern ANY_CHAR
Pattern
that matches any character and only mismatches for an empty string.public static final Pattern EOF
Pattern
object that matches if the input has no character left. Match length is 0
if succeed.public static final Pattern ESCAPED
Pattern
object that succeeds with match length 2
if there are at least 2 characters in the input
and the first character is '\'
. Mismatch otherwise.public static final Pattern STRICT_DECIMAL
Pattern
object that matches a decimal number that has at least one digit before the decimal point. The
decimal point and the numbers to the right are optional.
0, 11., 2.3
are all good candidates. While .1, .
are not.
public static final Pattern FRACTION
Pattern
object that matches a decimal point and one or more digits after it.public static final Pattern DECIMAL
Pattern
object that matches a decimal number that could start with a decimal point or a digit.public static final Pattern WORD
Pattern
object that matches a standard english word, which starts with either an underscore or an alpha
character, followed by 0 or more alphanumeric characters.public static final Pattern OCT_INTEGER
Pattern
object that matches an octal integer that starts with a 0
and is followed by 0 or more
[0 - 7]
characters.public static final Pattern DEC_INTEGER
Pattern
object that matches a decimal integer, which starts with a non-zero digit and is followed by 0 or
more digits.public static final Pattern HEX_INTEGER
Pattern
object that matches a hex integer, which starts with a 0x
or 0X
, and is followed
by one or more hex digits.public static final Pattern SCIENTIFIC_NOTATION
public static final Pattern REGEXP_PATTERN
Pattern
object that matches any regular expression pattern string in the form of /some pattern
here/
. '\'
is used as escape character.public static Pattern hasAtLeast(int n)
Pattern
object that matches if the input has at least n
characters left. Match length is
n
if succeed.public static Pattern hasExact(int n)
Pattern
object that matches if the input has exactly n
characters left. Match length is
n
if succeed.public static Pattern isChar(char c)
Pattern
object that matches if the current character in the input is equal to character c
, in which case 1
is returned as match length. Mismatches otherwise.public static Pattern range(char c1, char c2)
Pattern
object that matches if the current character in the input is between character c1
and c2
, in which case 1
is returned as match length.public static Pattern among(String chars)
Pattern
object that matches if the current character in the input is equal to any character in
chars
, in which case 1
is returned as match length.public static Pattern isChar(CharPredicate predicate)
Pattern
object that matches if the current character in the input satisfies predicate
, in
which case 1
is returned as match length.public static Pattern lineComment(String begin)
Pattern
object that matches a line comment started by begin
and ended by EOF
or
LF
(the line feed character).public static Pattern string(String string)
Pattern
object that matches string
literally.public static Pattern stringCaseInsensitive(String string)
Pattern
object that matches string
case insensitively.public static Pattern notString(String string)
Pattern
object that matches if the input has at least 1 character and doesn't match string
. 1
is returned as match length if succeeds.public static Pattern notStringCaseInsensitive(String string)
Pattern
object that matches if the input has at least 1 character and doesn't match string
case insensitively. 1
is returned as match length if succeeds.public static Pattern not(Pattern pattern)
pattern
- Pattern
that matches iff the input does not match nested pattern
.public static Pattern and(Pattern... patterns)
Pattern
that matches if all of patterns
matches, in which case, the maximum match length
is returned. Mismatch if any one mismatches.public static Pattern or(Pattern... patterns)
Pattern
that matches if any of patterns
matches, in which case, the first match length is
returned. Mismatch if any one mismatches.public static Pattern sequence(Pattern... patterns)
Pattern
object that matches the input against patterns
sequentially. Te total match
length is returned if all succeed.public static Pattern repeat(int n, CharPredicate predicate)
Pattern
object that matches if the input has at least n
characters and the first n
characters all satisfy predicate
.@Deprecated public static Pattern many(int min, CharPredicate predicate)
atLeast(int, CharPredicate)
instead.Pattern
object that matches if the input starts with min
or more characters and all
satisfy predicate
.public static Pattern atLeast(int min, CharPredicate predicate)
Pattern
object that matches if the input starts with min
or more characters and all
satisfy predicate
.public static Pattern many(CharPredicate predicate)
Pattern
that matches 0 or more characters satisfying predicate
.@Deprecated public static Pattern some(int min, int max, CharPredicate predicate)
times(int, int, CharPredicate)
instead.Pattern
that matches at least min
and up to max
number of characters satisfying
predicate
,public static Pattern times(int min, int max, CharPredicate predicate)
Pattern
that matches at least min
and up to max
number of characters satisfying
predicate
,@Deprecated public static Pattern some(int max, CharPredicate predicate)
atMost(int, CharPredicate)
instead.public static Pattern atMost(int max, CharPredicate predicate)
public static Pattern longer(Pattern p1, Pattern p2)
Pattern
that tries both p1
and p2
,
and picks the one with the longer match length.
If both have the same length, p1
is favored.public static Pattern longest(Pattern... patterns)
Pattern
that tries all of patterns
, and picks the one with the
longest match length. If two patterns have the same length, the first one is favored.public static Pattern shorter(Pattern p1, Pattern p2)
Pattern
that tries both p1
and p2
, and picks the one with the shorter match
length. If both have the same length, p1
is favored.public static Pattern shortest(Pattern... patterns)
Pattern
that tries all of patterns
, and picks the one with the shortest match length. If
two patterns have the same length, the first one is favored.public static Pattern many1(CharPredicate predicate)
Pattern
that matches 1 or more characters satisfying predicate
.public static Pattern regex(Pattern p)
Pattern
.
WARNING: in addition to regular expression cost, the returned Pattern
object needs
to make a substring copy every time it's evaluated. This can incur excessive copying and memory overhead
when parsing large strings. Consider implementing Pattern
manually for large input.
public static Pattern regex(String s)
Pattern
.
WARNING: in addition to regular expression cost, the returned Pattern
object needs
to make a substring copy every time it's evaluated. This can incur excessive copying and memory overhead
when parsing large strings. Consider implementing Pattern
manually for large input.
Copyright © 2013–2018 jparsec. All rights reserved.