REGEX Remove Space

前端 未结 5 1439
我寻月下人不归
我寻月下人不归 2020-12-20 07:44

I want to creating regex to remove some matching string, the string is phone number

Example user input phone number like this:

+jfalkjfkl saj f62 81 78

5条回答
  •  甜味超标
    2020-12-20 07:59

    Using PCRE regexes, you should be able to simply remove anything matching \D+. Example:

    echo "+jfalkjfkl saj f62 81 7876 asdadad30 asasda36" | perl -pe 's/\D+//g'
    

    prints:

    628178763036
    

提交回复
热议问题