Grodo Posted July 31, 2007 Share Posted July 31, 2007 Whats wrong with my preg_replace? It strips the numbers but it also strips the - (dash) from the string. I wanted it to grab just the numbers $db_fax = preg_replace("/[a-zA-Z]/xms","",$db_fax); Thanx like always Grodo Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/ Share on other sites More sharing options...
effigy Posted August 1, 2007 Share Posted August 1, 2007 What's the input and output? Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/#findComment-312547 Share on other sites More sharing options...
clearstatcache Posted August 1, 2007 Share Posted August 1, 2007 if you want to remove only the numbers...try ds... $db_fax = preg_replace("/[0-9]/xms","",$db_fax); and if you want to get only the numbers...try ds.... $db_fax = preg_replace("/[^0-9]/xms","",$db_fax); Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/#findComment-312633 Share on other sites More sharing options...
DeadEvil Posted August 1, 2007 Share Posted August 1, 2007 $db_fax = preg_replace("/[a-zA-Z-]/xms","",$db_fax); Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/#findComment-312640 Share on other sites More sharing options...
clearstatcache Posted August 1, 2007 Share Posted August 1, 2007 if you want to remove only the numbers...try ds... $db_fax = preg_replace("/[0-9]/","",$db_fax); and if you want to get only the numbers...try ds.... $db_fax = preg_replace("/[^0-9]/","",$db_fax); Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/#findComment-312642 Share on other sites More sharing options...
Grodo Posted August 1, 2007 Author Share Posted August 1, 2007 Thanx clearstatcache and Dead Evil! Everything works! Link to comment https://forums.phpfreaks.com/topic/62745-solved-preg_replace/#findComment-313054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.