Perl5Util.match "Searches for the FIRST pattern match somewhere in a String....". Hence, it would match "AABB12.2453333l3l3lacbblclcl" as you have posed it. If you insist on using this form, insert the Perl syntax for beginning and end of string.
Preferable for a number of reasons would be to compile a Pattern (that way you can test the validity of the "regexp" String passed into your method), precompile your regexes first so you don't need to recompile them for every input validation, then to pass the Pattern to a PatternMatcher in a PatternMatcher.matches(String,Pattern) method call. This will match the pattern EXACTLY. The PatternMatcher.contains(String,Pattern) method would do what your syntax is doing -- just testing whether the pattern is contained SOMEWHERE in the input string being validated. Perl5Util.matcher() does all this, but recompiles the regex into a Pattern each time you call it, hence will not give you best performance. Kevin Markey -----Original Message----- From: Keast Ann [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 05, 2005 10:18 AM To: [email protected] Subject: Regex Works on Oro Test Applet but doesn't work in code using oro 2.08 I am using jarkarta-oro-2.0.8 to do some input validation. I have a simple method: import org.apache.oro.text.perl.Perl5Util; public static boolean matchRegexp(String value, String regexp) { if (regexp == null || regexp.length() <= 0) { return false; } Perl5Util matcher = new Perl5Util(); return matcher.match("/" + regexp + "/", value); } And it works fine in all cases with the regexp = (\\d{0,2})(\\.)(\\d{0,4}) except for when value = 0.11000000000000000055511151231257827021181583404541015625 I expected this value to fail because it's greater than 4 digits after the decimal point. But it actually passes! It works on the applet at: http://jakarta.apache.org/oro/demo.html ( using: (\d{0,2})(\.)(\d{0,4}) ) but it doesn't work in my code using jarkarta-oro-2.0.8. Any ideas on why this is occuring? Thanks, Ann CONFIDENTIALITY NOTICE: This electronic mail transmission and any accompanying documents contain information belonging to Silver Creek Systems, Inc. that may be confidential and legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or action taken in reliance on the information is strictly prohibited. If you have received the information in error, please contact the sender by reply email and destroy all copies of the original email. Thank You. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
