mysterbx Posted February 12, 2008 Share Posted February 12, 2008 hola, what delimeter should i use to find an exact word in a pettern.. example: $pass = "login"; if(preg_match("#(login|register|signup)#", $pass, $passwordcheck2)) { echo "do somethin"; } the preg match would find a match example #2 (preg match should find a match) $pass = "loginregister"; if(preg_match("#(login|register|signup)#", $pass, $passwordcheck2)) { echo "do somethin"; } Quote Link to comment Share on other sites More sharing options...
effigy Posted February 12, 2008 Share Posted February 12, 2008 Word Boundaries. Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 12, 2008 Author Share Posted February 12, 2008 I tried preg_match("\b(login|register|signup)\b", $pass, $passwordcheck2) doesnt work... Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 12, 2008 Author Share Posted February 12, 2008 i read that article, but I dont know how to match the one word only... if preg match finds the needed word, it doesnt count it... Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 12, 2008 Author Share Posted February 12, 2008 got it: preg_match("~^\bjoin\b$~", $pass2, $passwordcheck2)) but how can i match word "join" to "JOIN" (join=JOIN=jOIN=Join) ... i think you get the point... Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2008 Share Posted February 13, 2008 There's no need to use word boundaries if you're using anchors. /\Ajoin\z/i Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 13, 2008 Author Share Posted February 13, 2008 that help a lot, 3 bugs were fixed could you look at this topic: http://www.phpfreaks.com/forums/index.php/topic,181443.0.html ? topic solved... 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.