fix(guide): correct regex for intermediate solution code (#35784)

pull/31201/head^2
lasjorg 2019-05-25 08:45:26 +02:00 committed by Randell Dawson
parent 705c781d19
commit c852dc7d1d
1 changed files with 1 additions and 1 deletions

View File

@ -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");