Searching for phone numbers in mysql

后端 未结 16 2611
耶瑟儿~
耶瑟儿~ 2020-12-30 06:40

I have a table which is full of arbitrarily formatted phone numbers, like this

027 123 5644
021 393-5593
(07) 123 456
042123456

I need to sea

16条回答
  •  余生分开走
    2020-12-30 06:52

    MySQL can search based on regular expressions.

    Sure, but given the arbitrary formatting, if my haystack contained "(027) 123 456" (bear in mind position of spaces can change, it could just as easily be 027 12 3456 and I wanted to match it with 027123456, would my regex therefore need to be this?

    "^[\D]+0[\D]+2[\D]+7[\D]+1[\D]+2[\D]+3[\D]+4[\D]+5[\D]+6$"
    

    (actually it'd be worse as the mysql manual doesn't seem to indicate it supports \D)

    If that is the case, isn't it more or less the same as my %%%%% idea?

提交回复
热议问题