kee2ka4 Posted October 30, 2009 Share Posted October 30, 2009 Hey peeps, I have the following regular expression rule, that validates the email address: 'email' => '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,4}$/', But when I input test@test.com it passes but when I input test@test.co.uk it fails. Is my regular expression incorrect? Could anyone plz show me some light here.. Thanks :-) Quote Link to comment Share on other sites More sharing options...
Mchl Posted October 30, 2009 Share Posted October 30, 2009 [a-zA-Z0-9-]+\.[a-zA-Z.]{2,4} does not match test.co.uk. Count dots. And remember: unescaped dot stands for any character. Quote Link to comment Share on other sites More sharing options...
kee2ka4 Posted October 30, 2009 Author Share Posted October 30, 2009 Ah.. thanks man I get it.. i changed it to 6 at the end.. Thanks man :-) Quote Link to comment Share on other sites More sharing options...
salathe Posted October 30, 2009 Share Posted October 30, 2009 And remember: unescaped dot stands for any character. Not inside character classes; [.] will match a literal dot only. Quote Link to comment Share on other sites More sharing options...
Mchl Posted October 30, 2009 Share Posted October 30, 2009 Not inside character classes; [.] will match a literal dot only. Yeah... I forgot about that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.