remove special characters from a phone number
php, regex
Solution
You are mixing up languages. The first line of code is indeed PHP, but the second is JS?
Although you are looking for the function preg_replace
$ph_number = preg_replace("/[^0-9]/", "", $ph_number);
Problem
I need to remove all the special characters in a phone number. for ex my phone numbers look like this `+91-5345534534`, `040-545453453` Finally, I need all the ph numbers should be in unique format like `915345534534`, `040545453453` I need a regular expression for this to do in php. I am trying like this ``` $ph_number = "+91-5345534534"; filterNum = filterNum.replaceAll("[^0-9]+", $ph_number); ``` but, this is not working. Please help me in that.