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"; } Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/ Share on other sites More sharing options...
effigy Posted February 12, 2008 Share Posted February 12, 2008 Word Boundaries. Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-464931 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... Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-464999 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... Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-465019 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... Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-465322 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 Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-465964 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... Link to comment https://forums.phpfreaks.com/topic/90699-find-exact-word/#findComment-466195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.