Note: matches() is not the same as sticking a ^ in front of your expression and a $ at the end of your expression in Perl5 and using the =~ operator, even though in many cases it will be equivalent. matches() literally looks for an exact match according to the rules of Perl5 expression matching. Therefore, if you have a pattern foo|foot and are matching the input foot it will not produce an exact match. But foot|foo will produce an exact match for either foot or foo. Remember, Perl5 regular expressions do not match the longest possible match. From the perlre manpage:
Alternatives are tried from left to right, so the first alternative found for which the entire expression matches, is the one that is chosen. This means that alternatives are not necessarily greedy. For example: when matching foo|foot against "barefoot", only the "foo" part will match, as that is the first alternative tried, and it successfully matches the target string.
@param input The char[] to test for an exact match. @param pattern The Perl5Pattern to be matched. @return True if input matches pattern, false otherwise. @exception ClassCastException If a Pattern instance other than aPerl5Pattern is passed as the pattern parameter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|