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? 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. Link to comment https://forums.phpfreaks.com/topic/191523-question/#findComment-1009613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.