codrgii Posted February 9, 2010 Share Posted February 9, 2010 i'm having trouble with preg_replace, how do i make it that the preg_replace replaces any characters thats not in the list of a-z,A-Z,0-9 and only allow the characters ' ', '-', '(', ')' to be entered? Quote Link to comment https://forums.phpfreaks.com/topic/191523-question/ Share on other sites More sharing options...
wildteen88 Posted February 9, 2010 Share Posted February 9, 2010 Use a character set $text = 'abcd 14-2334-8896 56"#@(55)'; $text = preg_replace('~[^a-z0-9\(\)\- ]~i', '', $text); echo $text; http://regular-expressions.info is a good site for understanding regular expressions. Quote Link to comment https://forums.phpfreaks.com/topic/191523-question/#findComment-1009613 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.