Last active
February 14, 2023 12:40
-
-
Save dcortesnet/271145ba70f89277a8289ca9f64e1f14 to your computer and use it in GitHub Desktop.
Javascript valiación número tel eeuu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$ | |
| function isEEUUPhoneNumber(number) { | |
| const reg = /[-+]?(?:\d{1,2}\s)?\(*(?:\d{3})(?:-|\)|\)\s|\s)*\d{3}(?:-|\s)*\d{4}/; | |
| return reg.test(number); | |
| } | |
| console.log(isEEUUPhoneNumber("1(555)555-5555")); // true | |
| console.log(isEEUUPhoneNumber("(555)555-5555")); // false | |
| console.log(isEEUUPhoneNumber("2(757)6227382")); //false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment