Try this:
preg_replace('/[^0-9]/', '', '604-619-5135');
preg_replace uses PCREs which generally start and end with a /
.
More Related Contents:
- Find a match pattern of any digit and space with any character in a string and replace with | in PHP [closed]
- Remove new lines from string and replace with one empty space
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- Capturing text between square brackets in PHP
- Remove multiple whitespaces
- How do I remove all specific characters at the end of a string in PHP?
- How to remove non-alphanumeric characters?
- How to mimic Stack Overflow Auto-Link Behavior
- Remove control characters from PHP string
- How to split a string by multiple delimiters in PHP?
- Convert string into slug with single-hyphen delimiters only
- PHP remove special character from string
- Split camelCase word into words with php preg_match (Regular Expression)
- string sanitizer for filename
- How to split a long string without breaking words?
- Php – regular expression to check if the string has chinese chars
- Validating US phone number with php/regex
- PHP – Add link to a URL in a string
- Get last whole number in a string
- Close open HTML tags in a string
- Regex & PHP – isolate src attribute from img tag
- Remove accents without using iconv
- How to prefix a positive number with plus sign in PHP
- How to remove numbers from a string with RegEx
- How to validate that a string only contain lowercase letters?
- Regex to match an IP address [closed]
- startsWith() and endsWith() functions in PHP
- Get first 100 characters from string, respecting full words
- PHP and regexp to accept only Greek characters in form
- How do I detect non-ASCII characters in a string?