|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Untamed:
Method Summary | |
boolean |
contains(char[] input,
Pattern pattern)
Enabled: Determines if a string (represented as a char[]) contains a pattern. |
boolean |
contains(PatternMatcherInput input,
Pattern pattern)
Enabled: Determines if the contents of a PatternMatcherInput, starting from the current offset of the input contains a pattern. |
boolean |
contains(String input,
Pattern pattern)
Enabled: Determines if a string contains a pattern. |
MatchResult |
getMatch()
Enabled: Fetches the last match found by a call to a matches() or contains() method. |
boolean |
matches(char[] input,
Pattern pattern)
Enabled: Determines if a string (represented as a char[]) exactly matches a given pattern. |
boolean |
matches(PatternMatcherInput input,
Pattern pattern)
Enabled: Determines if the contents of a PatternMatcherInput instance exactly matches a given pattern. |
boolean |
matches(String input,
Pattern pattern)
Enabled: Determines if a string exactly matches a given pattern. |
boolean |
matchesPrefix(char[] input,
Pattern pattern)
Enabled: Determines if a prefix of a string (represented as a char[]) matches a given pattern. |
boolean |
matchesPrefix(char[] input,
Pattern pattern,
int offset)
Enabled: Determines if a prefix of a string (represented as a char[]) matches a given pattern, starting from a given offset into the string. |
boolean |
matchesPrefix(PatternMatcherInput input,
Pattern pattern)
Enabled: Determines if a prefix of a PatternMatcherInput instance matches a given pattern. |
boolean |
matchesPrefix(String input,
Pattern pattern)
Enabled: Determines if a prefix of a string matches a given pattern. |
Method Detail |
public boolean matchesPrefix(char[] input, Pattern pattern, int offset)
getMatch()
.
This method is useful for certain common token identification tasks that are made more difficult without this functionality.
input
- The char[] to test for a prefix match.pattern
- The Pattern to be matched.offset
- The offset at which to start searching for the prefix.
public boolean matchesPrefix(String input, Pattern pattern)
getMatch()
.
This method is useful for certain common token identification tasks that are made more difficult without this functionality.
input
- The String to test for a prefix match.pattern
- The Pattern to be matched.
public boolean matchesPrefix(char[] input, Pattern pattern)
getMatch()
.
This method is useful for certain common token identification tasks that are made more difficult without this functionality.
input
- The char[] to test for a prefix match.pattern
- The Pattern to be matched.
public boolean matchesPrefix(PatternMatcherInput input, Pattern pattern)
getMatch()
. Unlike the
contains(PatternMatcherInput, Pattern)
method, the current offset of the PatternMatcherInput argument
is not updated. You should remember that the region starting
from the begin offset of the PatternMatcherInput will be
tested for a prefix match.
This method is useful for certain common token identification tasks that are made more difficult without this functionality.
input
- The PatternMatcherInput to test for a prefix match.pattern
- The Pattern to be matched.
public boolean matches(String input, Pattern pattern)
getMatch()
.
input
- The String to test for an exact match.pattern
- The Pattern to be matched.
public boolean matches(char[] input, Pattern pattern)
getMatch()
.
input
- The char[] to test for a match.pattern
- The Pattern to be matched.
public boolean matches(PatternMatcherInput input, Pattern pattern)
getMatch()
. Unlike the
contains(PatternMatcherInput, Pattern)
method, the current offset of the PatternMatcherInput argument
is not updated. You should remember that the region between
the begin and end offsets of the PatternMatcherInput will be
tested for an exact match.
input
- The PatternMatcherInput to test for a match.pattern
- The Pattern to be matched.
public boolean contains(String input, Pattern pattern)
getMatch()
. If you want to access
subsequent matches you should either use a PatternMatcherInput object
or use the offset information in the MatchResult to create a substring
representing the remaining input. Using the MatchResult offset
information is the recommended method of obtaining the parts of the
string preceeding the match and following the match.
input
- The String to test for a match.pattern
- The Pattern to be matched.
public boolean contains(char[] input, Pattern pattern)
getMatch()
. If you want to access
subsequent matches you should either use a PatternMatcherInput object
or use the offset information in the MatchResult to create a substring
representing the remaining input. Using the MatchResult offset
information is the recommended method of obtaining the parts of the
string preceeding the match and following the match.
input
- The String to test for a match.pattern
- The Pattern to be matched.
public boolean contains(PatternMatcherInput input, Pattern pattern)
getMatch()
. The current offset of the
PatternMatcherInput is set to the offset corresponding to the end
of the match, so that a subsequent call to this method will continue
searching where the last call left off. You should remember that the
region between the begin and end offsets of the PatternMatcherInput are
considered the input to be searched, and that the current offset
of the PatternMatcherInput reflects where a search will start from.
Matches extending beyond the end offset of the PatternMatcherInput
will not be matched. In other words, a match must occur entirely
between the begin and end offsets of the input. See
PatternMatcherInput
for more details.
This method is usually used in a loop as follows:
PatternMatcher matcher; PatternCompiler compiler; Pattern pattern; PatternMatcherInput input; MatchResult result; compiler = new Perl5Compiler(); matcher = new Perl5Matcher(); try { pattern = compiler.compile(somePatternString); } catch(MalformedPatternException e) { System.out.println("Bad pattern."); System.out.println(e.getMessage()); return; } input = new PatternMatcherInput(someStringInput); while(matcher.contains(input, pattern)) { result = matcher.getMatch(); // Perform whatever processing on the result you want. }
input
- The PatternMatcherInput to test for a match.pattern
- The Pattern to be matched.
public MatchResult getMatch()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |