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 Quote Link to comment Share on other sites More sharing options...
effigy Posted August 1, 2007 Share Posted August 1, 2007 What's the input and output? Quote Link to comment 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); Quote Link to comment 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); Quote Link to comment 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); Quote Link to comment 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! 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.