fix(guide): correct regex for intermediate solution code (#35784)
parent
705c781d19
commit
c852dc7d1d
|
@ -93,7 +93,7 @@ Start by trying to get it to validate each format from the example, each one sho
|
||||||
## ![:sunflower:](https://forum.freecodecamp.com/images/emoji/emoji_one/sunflower.png?v=3 ":sunflower:") Intermediate Code Solution:
|
## ![:sunflower:](https://forum.freecodecamp.com/images/emoji/emoji_one/sunflower.png?v=3 ":sunflower:") Intermediate Code Solution:
|
||||||
|
|
||||||
function telephoneCheck(str) {
|
function telephoneCheck(str) {
|
||||||
var re = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/;
|
var re = /^([+]?1[\s]?)?((?:[(](?:[2-9]1[02-9]|[2-9][02-8][0-9])[)][\s]?)|(?:(?:[2-9]1[02-9]|[2-9][02-8][0-9])[\s.-]?)){1}([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2}[\s.-]?){1}([0-9]{4}){1}$/;
|
||||||
return re.test(str);
|
return re.test(str);
|
||||||
}
|
}
|
||||||
telephoneCheck("555-555-5555");
|
telephoneCheck("555-555-5555");
|
||||||
|
|
Loading…
Reference in New Issue