In message <[EMAIL PROTECTED]>, Kayiti Devan
andam writes:
>For the regular Expression \d{3}[.]\d{2}[.]\d{2}|\d{3}[.]\d{2}|\d{3}
>"123" string fails. But for 123.45 passes. (123 fails but it actually should
>have successfully validated since it correctly validated by the last OR
>Expression \d{3}...so it should have been validated.
Still need a test case that reproduces the problem. For example, I still
don't know if you're talking about contains or matches. In any case,
I can find no problem:
java examples.matchResultExample '\d{3}[.]\d{2}[.]\d{2}|\d{3}[.]\d{2}|\d{3}' 123
Match: 123
Length: 3
Groups: 1
Begin offset: 0
End offset: 3
Groups:
java examples.matchResultExample '\d{3}[.]\d{2}[.]\d{2}|\d{3}[.]\d{2}|\d{3}'
123.45
Match: 123.45
Length: 6
Groups: 1
Begin offset: 0
End offset: 6
Groups:
java examples.matchResultExample '\d{3}[.]\d{2}[.]\d{2}|(\d{3}[.]\d{2}|\d{3})'
123
Match: 123
Length: 3
Groups: 2
Begin offset: 0
End offset: 3
Groups:
1: 123
Begin: 0
End: 3
java examples.matchResultExample '\d{3}[.]\d{2}[.]\d{2}|(\d{3}[.]\d{2}|\d{3})'
123.45
Match: 123.45
Length: 6
Groups: 2
Begin offset: 0
End offset: 6
Groups:
1: 123.45
Begin: 0
End: 6
Those runs are using the matchResultExample program from src/java/examples.
I tested matches() using the demo applet with:
Perl5 Expression: \d{3}[.]\d{2}[.]\d{2}|\d{3}[.]\d{2}|\d{3}
Search Input: 123
Search Results:
Compiling regular expression.
Searching
The input IS an EXACT match.
Usually, the issue with matches() is the "foo|foot" issue, requiring one
to change the expression to start with ^ and end with $ to force the
extra backtracking. But that doesn't seem to be the case here.
At any rate, I can't reproduce the behavior. Assuming version 2.0.5
was not a typo, then maybe there was a bug in 2.0.5 that was fixed
by version 2.0.8. However, just to be completely thorough, I downloaded
version 2.0.5 and:
java -classpath ./jakarta-oro-2.0.5.jar:. examples.matchResultExample
'\d{3}[.]\d{2}[.]\d{2}|\d{3}[.]\d{2}|\d{3}' 123
Match: 123
Length: 3
Groups: 1
Begin offset: 0
End offset: 3
Groups:
I can't reproduce the reported behavior in any way. Assuming the problem
exists in an even earlier version of the library, then perhaps you've got
an earlier version sitting in your classpath. That happens sometimes
when using application servers since the software was included in most
of the major J2EE servers for a period of time. But without a test
program, all I can do is speculate and guess. The quickest way to
resolve these issues is to post self-contained code that reproduces
the problem. That way we can figure out if the problem is in the
library, in the code, or something else.
daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]