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"; } ?> } Link to comment https://forums.phpfreaks.com/topic/247747-expression-help/ 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. Link to comment https://forums.phpfreaks.com/topic/247747-expression-help/#findComment-1272233 Share on other sites More sharing options...
Destramic Posted September 26, 2011 Author Share Posted September 26, 2011 that worked great...thanks mate Link to comment https://forums.phpfreaks.com/topic/247747-expression-help/#findComment-1272903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.