Phone number normalization: Any pre-existing libraries?

前端 未结 5 885
不知归路
不知归路 2021-02-05 07:35

I have a system which is using phone numbers as unique identifiers. For this reason, I want to format all phone numbers as they come in using a normalized format. Because I have

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 08:16

    Just strip out any non-digits, possibly using a RegEx: [^\d]

    The only exception might be if you want to handle extensions, to distinguish a number without an area code but with a 3 digit extension, or if you need to handle international numbers.

提交回复
热议问题