nikefido Posted June 4, 2008 Share Posted June 4, 2008 I need some regex to replace characters you'd find in a phone number, such as spaces, periods, dashes, slashes. Can anyone help me get started with some regex? Quote Link to comment Share on other sites More sharing options...
effigy Posted June 4, 2008 Share Posted June 4, 2008 What do you want the final result to be? Numbers only? Quote Link to comment Share on other sites More sharing options...
nikefido Posted June 4, 2008 Author Share Posted June 4, 2008 $fixed = preg_replace('/[\. \- \s]/', '/', $phone); Quote Link to comment Share on other sites More sharing options...
effigy Posted June 4, 2008 Share Posted June 4, 2008 /\D+/ would be more encompassing. Quote Link to comment Share on other sites More sharing options...
nikefido Posted June 4, 2008 Author Share Posted June 4, 2008 /\D+/ would be more encompassing. wouldn't that replace...everything? not just the things between the numbers? or is \D any non-numeric? Quote Link to comment Share on other sites More sharing options...
effigy Posted June 4, 2008 Share Posted June 4, 2008 \D = non-digit. Quote Link to comment Share on other sites More sharing options...
nikefido Posted June 4, 2008 Author Share Posted June 4, 2008 tyvm, change made 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.