Destramic Posted September 23, 2011 Share Posted September 23, 2011 hey guys im having a problem with finding out if i string has the followeing... a-z, 0-9, /, _, - and white spaces...im not sure why it is returning false when the charters in the $uri variable are allowed characters...maybe a expression problem if anyone can help please on shy its not working...thank you <?php protected function is_uri_friendly($uri) { $uri = "game/counter-strike/league/test"; if (preg_match('#[^a-z0-9/-_]#i', $uri) > 0) { echo "$uri contain invalid characters\n"; }else { echo "$uri DOES NOT contain invalid characters.\n"; } ?> } Quote Link to comment Share on other sites More sharing options...
.josh Posted September 24, 2011 Share Posted September 24, 2011 it's because the /-_ part of your negative char class is being interpreted as a range of chars between / and _ you need to either escape the hyphen or put it at the beginning or end of the list. Quote Link to comment Share on other sites More sharing options...
Destramic Posted September 26, 2011 Author Share Posted September 26, 2011 that worked great...thanks mate 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.