Remove all non-numeric characters from a string; [^0-9] doesn’t match as expected

Try this:

preg_replace('/[^0-9]/', '', '604-619-5135');

preg_replace uses PCREs which generally start and end with a /.

Leave a Comment