Posted By

dbug13 on 08/13/08

Tagged

regex php textmate

Viewed 3 times

Strip phone number of all non alpha-numeric characters


/ Published in: PHP


  1. <?php
  2.  
  3. /**
  4.  * Strip a Phone number of all non alphanumeric characters
  5.  */
  6. $phone = "+1(555)-555-1212";
  7. $phone = preg_replace('/(\W*)/', '', $phone);
  8. print $phone;
  9.  
  10. // Result: 15555551212
  11.  
  12. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.