Interface Pattern
- All Known Implementing Classes:
Pattern
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionCreates a predicate that tests if this pattern matches a given input string.Creates a predicate that tests if this pattern is found in a given input string.int
flags()
matcher
(CharSequence subject) boolean
matches
(CharSequence subject) boolean
matches
(CharSequence subject, int regionStart) boolean
matches
(CharSequence subject, int regionStart, int regionEnd) pattern()
String[]
split
(CharSequence input) String[]
split
(CharSequence input, int limit) splitAsStream
(CharSequence input) Creates a stream from the given input sequence around matches of this pattern.
-
Field Details
-
CANON_EQ
static final int CANON_EQ- See Also:
-
CASE_INSENSITIVE
static final int CASE_INSENSITIVE -
COMMENTS
static final int COMMENTS- See Also:
-
DOTALL
static final int DOTALL- See Also:
-
LITERAL
static final int LITERAL- See Also:
-
MULTILINE
static final int MULTILINE- See Also:
-
UNICODE_CASE
static final int UNICODE_CASE- See Also:
-
UNIX_LINES
static final int UNIX_LINES- See Also:
-
UNICODE_CHARACTER_CLASS
static final int UNICODE_CHARACTER_CLASS
-
-
Method Details
-
pattern
String pattern()- See Also:
-
matcher
- See Also:
-
flags
int flags()- See Also:
-
matches
Equivalent withpattern.
matcher
(
subject).
matches
()
, but is slightly faster because it does not expose theMatcher
object and can thus save some overhead.- Returns:
- Whether the subject matches this pattern
-
matches
Equivalent withpattern.
matcher
(
subject).
region
(
regionStart,
subject.length()).
matches
()
, but is slightly faster because it does not expose theMatcher
object and can thus save some overhead.- Returns:
- Whether the substring of the subject, starting at regionStart, matches this pattern
-
matches
Equivalent withpattern.
matcher
(
subject).
region
(
regionStart,
regionEnd).
matches
()
, but is slightly faster because it does not expose theMatcher
object and can thus save some overhead.- Returns:
- Whether the substring of the subject, designated by regionStart and regionEnd, matches this pattern
-
split
- See Also:
-
split
- See Also:
-
asPredicate
Creates a predicate that tests if this pattern is found in a given input string.API Note: This method creates a predicate that behaves as if it creates a matcher from the input sequence and then calls find, for example a predicate of the form:
s -> matcher(s).find();
- Returns:
- The predicate which can be used for finding a match on a subsequence of a string
- Since:
- JRE 1.8
-
asMatchPredicate
Creates a predicate that tests if this pattern matches a given input string.API Note: This method creates a predicate that behaves as if it creates a matcher from the input sequence and then calls matches, for example a predicate of the form:
s -> matcher(s).matches();
- Returns:
- The predicate which can be used for matching an input string against this pattern.
- Since:
- JRE 11
-
splitAsStream
Creates a stream from the given input sequence around matches of this pattern. The stream returned by this method contains each substring of the input sequence that is terminated by another subsequence that matches this pattern or is terminated by the end of the input sequence. The substrings in the stream are in the order in which they occur in the input. Trailing empty strings will be discarded and not encountered in the stream.If this pattern does not match any subsequence of the input then the resulting stream has just one element, namely the input sequence in string form.
When there is a positive-width match at the beginning of the input sequence then an empty leading substring is included at the beginning of the stream. A zero-width match at the beginning however never produces such empty leading substring.
If the input sequence is mutable, it must remain constant during the execution of the terminal stream operation. Otherwise, the result of the terminal stream operation is undefined.
- Parameters:
input
- The character sequence to be split- Returns:
- The stream of strings computed by splitting the input around matches of this pattern
- Since:
- JRE 1.8
-