Modifier and Type | Method and Description |
---|---|
static Optional<Matcher> |
find(Pattern pattern,
CharSequence input)
Attempts to find the first subsequence of the input sequence that matches the
given pattern.
|
static Optional<Matcher> |
matches(Pattern pattern,
CharSequence input)
Attempts to match the entire region against the pattern.
|
static String |
quote(CharSequence input)
Returns a pattern string matching exactly
input . |
public static Optional<Matcher> find(Pattern pattern, CharSequence input)
Use Strings.find(CharSequence, Pattern)
if you do not need a
matcher.
pattern
- the patterninput
- the input sequence to find the pattern inMatcher
object or else Optional.empty()
is
returnedpublic static Optional<Matcher> matches(Pattern pattern, CharSequence input)
Use Strings.matches(CharSequence, Pattern)
if you do not need
a matcher.
pattern
- the patterninput
- the input sequence to match against the patternMatcher
object or else Optional.empty()
is
returnedpublic static String quote(CharSequence input)
input
.
This method escapes character-wise, while the original
Pattern.quote(String)
uses escapes sequences using \Q
and
\E
.
Example: C:\test.txt
results in C:\\test\.txt
.
input
- the string to be literalizedCopyright © 2025. All rights reserved.