ereg_replace到preg_replace(英文电话号码)

Regex seems to be my kryptonite.

How do I convert:

ereg_replace('[^0-9]+','',str_replace("+", "00", $number))

to:

preg([something])

Coming from: http://james.cridland.net/code/format_uk_phonenumbers.html Id tried changing the first parameter to /[^0-9]+ and `/[^0-9]+/, as well as both of those sans-quotes, but none worked. I'm afraid I'm a regex newbie.

You need to include the php delimiters inside the pattern part for preg_replace():

preg_replace('~[^0-9]+~', '', str_replace("+", "00", $number));
            //^       ^

Try this:

preg_replace("/[^[:alpha:][:space:]]+/ui", '', str_replace("+", "00", $number));

Coming from this question.

Character classes can be found here: https://php.net/manual/en/regexp.reference.character-classes.php