behaviour of Perl5Matcher.matches doesn't seem to properly take care of alternatives.

Tarun Ramakrishna Elankath <[email protected]> Wed, 04 Feb 2004 17:50:14 +0530
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <[email protected]>
Hi,

I have a zip code. It's length can be 5 digits, 9 digits or 12 digits.
My Perl5Pattern pattern (say ptn) is: \d{5}|\d{9}|\d{12}

I have input string, say zip5, zip9 and zip12 that are strings of digits 
of length 5, 9 and 12 respectively.

When I use Perl5Matcher.matches(), zip5 passed, but zip9 and zip 12 
fails. I tried the online demo and it failed there too.

If I re-arrange the pattern to be \d{9}|\d{5}|\d{12}, then zip9 passed 
but zip5 and zip12 fail.

For some reason, it only seems to consider the first alternative. Is 
this the expected functional behaviour ?

So, I am reduced to specifying my pattern as a cumbersome: 				 
^\d{5}$|^\d{9}$|^\d{12}$
and using Perl5Matcher.contains. This works fine.

All help/information much appreciated,
Thanks,
Tarun

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
InterScan_Disclaimer.txt (text/plain, 521 B)
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
prohibited and may be unlawful.

		Visit us at http://www.cognizant.com