php - Regex for 10-13 digit (international) phone numbers -
i need deliver (international) phone numbers php registration form external party. external party has following rules phone numbers.
- 10-13 digits
- dashes allowed
this means following numbers correct
- 0046701234567 (swedish)
- 604-555-5555
- 5675555555
what best (and correct) regex regulate , check phone numbers can store them in global database send them external party afterwards?
just try with:
$input = '604-555-5555'; if (preg_match('/^\d{10,13}$/', str_replace('-', '', $input))) { // valid }
Comments
Post a Comment