Friday, July 19, 2019

A comprehensive regex for phone number validation

I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:




  • 1-234-567-8901

  • 1-234-567-8901 x1234

  • 1-234-567-8901 ext1234


  • 1 (234) 567-8901

  • 1.234.567.8901

  • 1/234/567/8901

  • 12345678901



I'll answer with my current attempt, but I'm hoping somebody has something better and/or more elegant.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...