I need something besides [^0-9\n], I want a regex(but dont know how to make one), that captures anything in a pattern of numbers like this, "0000000000" or "000-000-0000" or basically any numbers that exist with spaces and or special characters right before or in between.
so any number, even like these (626*) 34a2- 4387) should convert to 6263424387
How can this be accomoplished? Im thinking its too hard?
To remove all characters except numbers in javascript, call the replace() method, passing it a regular expression that matches all non-number characters and replace them with an empty string. The replace method returns a new string with some or all of the matches replaced.
If you want to get only digits using REGEXP, use the following regular expression( ^[0-9]*$) in where clause. Case 1 − If you want only those rows which have exactly 10 digits and all must be only digit, use the below regular expression.
To match any character except a list of excluded characters, put the excluded charaters between [^ and ] . The caret ^ must immediately follow the [ or else it stands for just itself.
You can search for all non-digits using:
\D+
OR
[^0-9]+
And replace by empty string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With