Remove Phone number from string in PHP

后端 未结 3 1688
迷失自我
迷失自我 2020-12-22 02:23

i want to remove phone number with follow match

one two three four five six seven eight nine zero

i have tried following

3条回答
  •  悲哀的现实
    2020-12-22 03:23

    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);
    

提交回复
热议问题