Validating USA cell/mobile phone numbers with rege

2019-09-21 08:02发布

问题:

This question already has an answer here:

  • Regular expression to validate US phone numbers? [duplicate] 1 answer

I need to write validation to check if a phone number is a valid USA cell / mobile phone number. I have found examples for landlines but not cell / mobile phones. Can anyone point me in the right direction with this?

回答1:

you can use Google's phone number handling library. Maybe better than regex. Here: https://github.com/giggsey/libphonenumber-for-php