GD77 Posted December 6, 2012 Share Posted December 6, 2012 Hello, I m using the following to check on bad words upon an email validation: $badWords=array('...','...'); $words = array_map('preg_quote', $badWords); $words1 = implode('|', $words); if(!preg_match('/^[a-z0-9_\-\.]+@(?:[a-z0-9_\-]+\.)+(?:'.$Ext.')+$/', $user_email) || preg_match('/\b'.$words1.'\b/i', $user_email){} The email in question: ericbass213...why is it considering it as badword since it snot listed in the badwords array and yes when I ve disabled the badword validation the email workd fine. Thank Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/ Share on other sites More sharing options...
Jessica Posted December 6, 2012 Share Posted December 6, 2012 Is "ass" in your bad words list? *eyeroll* Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1397861 Share on other sites More sharing options...
GD77 Posted December 6, 2012 Author Share Posted December 6, 2012 yes of course but ericbass shouldn t be considered as one word? Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1397862 Share on other sites More sharing options...
Jessica Posted December 6, 2012 Share Posted December 6, 2012 I'm not good at regex but it would seem there's a problem with yours. Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1397864 Share on other sites More sharing options...
Christian F. Posted December 6, 2012 Share Posted December 6, 2012 To give you a small example of what Jessica refers to: php > $string = "This is clopenasticly wrong, for all testers and unclosed doors"; php > $RegExp = "/\\btest|open|closed\\b/"; php > var_dump (preg_match_all ($RegExp, $string, $matches)); int(3) php > var_dump ($matches); array(1) { [0]=> array(3) { [0]=> string(4) "open" [1]=> string(4) "test" [2]=> string(6) "closed" } } In other words, \b and | doesn't work quite the way you think. You'll need a non-capturing sub group in there too. Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1397909 Share on other sites More sharing options...
GD77 Posted December 10, 2012 Author Share Posted December 10, 2012 Thanks I have clearer image now so better to drop the bad words validation on an email specify most rated... Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1398543 Share on other sites More sharing options...
Christian F. Posted December 11, 2012 Share Posted December 11, 2012 You're welcome, and yeah: Generally you don't want to filter "bad" words from an e-mail address. It's extremely annoying when I can't sign up for a site, because they've deemed part of my last name a "bad word". (For those not in the know: "Fag" in Norwegian means subject/area of study/work.) Link to comment https://forums.phpfreaks.com/topic/271680-error-preg_match-bad-words-on-an-email/#findComment-1398631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.