I use the regular expression /^\+(90)[2-5]{1}[0-9]{9}$/ for phone validation, but when someone enters any special characters (such as * - / ( ) - _) in the input, I want to replace the characters with an empty string (remove them). Note that I don’t want to replace the +.
How can I do that?
This will remove all non-numeric characters in a given string:
\Dmatches anything that isn’t a number;\dmatches a number.Misread the question. To remove all non-numeric characters except
+, do: