Fog Juice Posted February 20, 2008 Share Posted February 20, 2008 Hey, How can I remove every character from a string other than 0 to 9? Thanks, Chris Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 20, 2008 Share Posted February 20, 2008 <?php $string = "I have values other then 0 45 7 and 432"; $string = preg_replace('/\D/','',$string); echo $string; ?> output: 0457432 Quote Link to comment Share on other sites More sharing options...
effigy Posted February 20, 2008 Share Posted February 20, 2008 <script type="text/javascript"> var re = /\D+/g; var str = '*+a1b2c3d4e5f6-%'; alert(str.replace(re, '')); </script> Quote Link to comment Share on other sites More sharing options...
Fog Juice Posted February 20, 2008 Author Share Posted February 20, 2008 <?php $string = "I have values other then 0 45 7 and 432"; $string = preg_replace('/\D/','',$string); echo $string; ?> output: 0457432 Considering this is the javascript part of phpfreaks.com, I was hoping to get a response with javascript in it lol Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 20, 2008 Share Posted February 20, 2008 Yeah...I was watching all the forums and missed which one this was actually in. And I know JS too...if only I read more carefully 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.