i want to remove phone number with follow match
one two three four five six seven eight nine zero
i have tried following
At the risk of teaching a man to fish...
I swear by regexbuddy when crafting regex patterns. They have a library of patterns for phone numbers as well. It's really easy to build a pattern and see its result. It's a swiss army knife for programming. I've used it for 7 years and it's always open on my computer.
Also, it can generate php code (as well as javascript, etc.) for a number of different scenarios.
I'm not totally sure what you're trying to do, but to start, you define $regexp
, but then reference $number_regexp
Check your regexp variable name
$regexp = "/[one|two|three|four|five|six|seven|eight|zero]{4,}/";
$message = preg_replace($regexp, 'XXX', $message);
For number 0 to 9
preg_replace("/[^0-9]/","",$message);
Use \d if you want to remove all digits
$message = preg_replace('/\d/', '', $message);
Or [^a-z\s] if you want to replace all except alphabets and whitespaces
$message = preg_replace('/[^a-z\s]/i', '', $message);