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 [email protected] it passes but when I input [email protected] it fails. Is my regular expression incorrect? Could anyone plz show me some light here.. Thanks :-) Link to comment https://forums.phpfreaks.com/topic/179613-solved-is-my-regular-expression-wrong/ 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. Link to comment https://forums.phpfreaks.com/topic/179613-solved-is-my-regular-expression-wrong/#findComment-947710 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 :-) Link to comment https://forums.phpfreaks.com/topic/179613-solved-is-my-regular-expression-wrong/#findComment-947735 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. Link to comment https://forums.phpfreaks.com/topic/179613-solved-is-my-regular-expression-wrong/#findComment-947763 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. Link to comment https://forums.phpfreaks.com/topic/179613-solved-is-my-regular-expression-wrong/#findComment-947790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.