Hi, I am trying to verify e-mail address format using the following regular expression:
"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)[EMAIL PROTECTED](\\.[A-Za-z0-9-]+)*$" I am getting different results when I use SDK 1.2.4 and Apache Regexp. It seems that the latter is less strict. For example, both statements: new RE(regex).match(fred&[EMAIL PROTECTED]); new RE(regex).match("[EMAIL PROTECTED]"); return true, which is not what I expect. I am sure I am doing something wrong, but what? Thanks, -- Victor ------------- Code example -------------- import org.apache.regexp.*; import junit.framework.TestCase; public class Driver extends TestCase { protected String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)[EMAIL PROTECTED](\\.[A-Za-z0-9-]+)*$"; public Driver(String name) { super(name); } private void assertNoMatch(String email) throws Exception { assertFalse("email.matches(\"" + email + "\")", email.matches(regex)); assertFalse("new RE(regex).match(\"" + email + "\")", new RE(regex).match(email)); } private void assertMatch(String email) throws Exception { assertTrue("email.matches(\"" + email + "\")", email.matches(regex)); assertTrue("new RE(regex).match(\"" + email + "\")", new RE(regex).match(email)); } public void test() throws Exception { assertMatch("[EMAIL PROTECTED]"); assertNoMatch("fred [EMAIL PROTECTED]"); assertNoMatch("fred&[EMAIL PROTECTED]"); assertNoMatch("[EMAIL PROTECTED]"); assertNoMatch("[EMAIL PROTECTED]"); } } ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]