Bug 16214 - Character escaping does not always work correctly in RegExp 1.2
Character escaping does not always work correctly in RegExp 1.2
Status: CLOSED DUPLICATE of bug 14954
Product: Regexp
Classification: Unclassified
Component: Other
unspecified
PC Linux
: P3 normal (vote)
: ---
Assigned To: Jakarta Notifications Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2003-01-17 16:30 UTC by Peter Nielsen
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Nielsen 2003-01-17 16:30:16 UTC
When matching the string "peter+n@bmtmicro.com", the following regular 
expression fails with RegExp 1.2. (It works fine in Javascript).

"^[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\.\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+\\@
(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"

These two expressions that do the same thing, work fine though:

"^[a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27
\\x2A\\x2B\\x2D\\x2E\\x2F\\x3D\\x3F\\x5E\\x5F\\x60\\x7B\\x7C\\x7D\\x7E]+\\@
(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")


"^[a-zA-Z0-9\\x21\\x23-\\x27\\x2A\\x2B\\x2D-\\x2F\\x3D\\x3F\\x5E-\\x60\\x7B-
\\x7E]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"

The code used for matching is as follows:

org.apache.regexp.RE re = new org.apache.regexp.RE (expression);
boolean result = re.match ("peter+n@bmtmicro.com");

where expression is one of the three regular expressions above.

All three expressions should return the result "true", but the first one 
returns "false" in RegExp 1.2. 

Please note: I am no specialist on regular expression syntax. However, to my 
best knowledge, these expressions should all return the same result. This has 
been verified by using JavaScript which has regex support. In JavaScript all 
three expressions evaluate true.

Thanks,
Peter Nielsen
BMT Micro, Inc.
Comment 1 Vadim Gritsenko 2003-04-25 13:26:45 UTC

*** This bug has been marked as a duplicate of 14954 ***
Comment 2 Vadim Gritsenko 2003-05-02 01:14:36 UTC
Fixed by Bug #19329