DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21706>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21706 Escaping '.' character does not work in some conditions Summary: Escaping '.' character does not work in some conditions Product: Regexp Version: unspecified Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: Other AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Normally escaping the dot ('.') character using a slash ('\') should make the regular expression consider this dot as a normal character and not the regexp equivalent for "any character". This seems to fail in some conditions, but can be fixed by surrounding the dot with double quotes to make it considered as a string. I don't have time to make a lot of tests but the code below will produce the following output with jdk1.3 and jakarta-regexp 1.2 or latest build as of July 18th 2003, in this output the test number 5 should, in fact, not fail. You can also see that test number 1 does not fail if dot character is surrounded with double quotes. ---- OUTPUT BEGIN ---- [1] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_"."\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [2] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_"."\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [3] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_"."\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [4] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_"."\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [5] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : false [6] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [7] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true [8] Checking "[EMAIL PROTECTED]" against "^(.*<)?([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(>)?$" : true ---- OUTPUT END ---- ---- CODE BEGIN ---- package retest; import org.apache.regexp.*; public class retest { public static void main(String args[]){ // List of email addresses to check String[] emailAddresses = new String[]{ "[EMAIL PROTECTED]", "[EMAIL PROTECTED]", "[EMAIL PROTECTED]", "[EMAIL PROTECTED]" }; // List of reg exp to use String[] regExp = new String[]{ "^(.*<)?([a-zA-Z0-9_\".\"\\-])+@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+(>)?$", "^(.*<)?([a-zA-Z0-9_\\.\\-])+@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+(>)?$" }; try{ int testCounter = 1; for (int i = 0; i < regExp.length; i++) { RE emailRE = new RE(regExp[i]); for (int j = 0; j < emailAddresses.length; j++) { System.out.println("["+ (testCounter++) +"]\tChecking\t\"" + emailAddresses[j] + "\"\tagainst\t\"" + regExp[i] + "\"\t:\t" + emailRE.match(emailAddresses[j])); } } } catch(Exception e){ System.out.println(e); } } } ---- CODE END ---- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]