REGEX Remove Space

前端 未结 5 1388
我寻月下人不归
我寻月下人不归 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:54

    Use a look-behind and a look-ahead to assert that digits must precede/follow the space(s):

    (?<=\d) +(?=\d)
    

    The entire regex matches the spaces, so no need to reference groups in your replacement, just replace with a blank.

提交回复
热议问题