No, that's wrong. In the above example, the ^ signifies the beginning of the string in that context, so it will remove the first character from the beginning of the string...
only if is a non-digit.
\d is a digit, equivalent to [0-9]
\D is a non-digit, equivalent to [^0-9]
Just as:
\w is a word character, equivalent to [A-Za-z0-9_]
\W is a non-word character, equivalent to [^A-Za-z0-9_]
\s is a whitespace character
\S is a non-whitespace character, equivalent to [^\s]
...etc.
So, yes DataTalk, the following code will remove all non-digits from the string:
PHP Code:
$string = preg_replace( '/\D/', '', $string );
The original suggestion will work, I just provided a simpler alternative. Learning the ins-and-outs of PCRE will take you a long way.