Return to Snippet

Revision: 7810
at August 13, 2008 16:53 by dbug13


Updated Code
<?php

/**
 * Strip a Phone number of all non alphanumeric characters
 */
$phone = "+1(555)-555-1212";
$phone = preg_replace('/(\W*)/', '', $phone);
print $phone;

// Result: 15555551212

?>

Revision: 7809
at August 13, 2008 16:52 by dbug13


Initial Code
<?php

/**
 * Strip a Phone number of all non alphanumeric characters
 */
$phone = "+1(555)-555-1212";
$phone = preg_replace('/(W*)/', '', $phone);
print $phone;

// Result: 15555551212

?>

Initial URL

                                

Initial Description

                                

Initial Title
Strip phone number of all non alpha-numeric characters

Initial Tags
regex, php, textmate

Initial Language
PHP