diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.english.md index 93a63d0e26..5ff356c338 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.english.md @@ -33,19 +33,19 @@ Change the regex haRegex to match the word "Hazzah" on ```yml tests: - text: Your regex should use curly brackets. - testString: assert(haRegex.source.match(/{.*?}/).length > 0, 'Your regex should use curly brackets.'); + testString: assert(haRegex.source.match(/{.*?}/).length > 0); - text: Your regex should not match "Hazzah" - testString: assert(!haRegex.test("Hazzah"), 'Your regex should not match "Hazzah"'); + testString: assert(!haRegex.test("Hazzah")); - text: Your regex should not match "Hazzzah" - testString: assert(!haRegex.test("Hazzzah"), 'Your regex should not match "Hazzzah"'); + testString: assert(!haRegex.test("Hazzzah")); - text: Your regex should match "Hazzzzah" - testString: assert(haRegex.test("Hazzzzah"), 'Your regex should match "Hazzzzah"'); + testString: assert("Hazzzzah".match(haRegex)[0].length === 8); - text: Your regex should match "Hazzzzzah" - testString: assert(haRegex.test("Hazzzzzah"), 'Your regex should match "Hazzzzzah"'); + testString: assert("Hazzzzzah".match(haRegex)[0].length === 9); - text: Your regex should match "Hazzzzzzah" - testString: assert(haRegex.test("Hazzzzzzah"), 'Your regex should match "Hazzzzzzah"'); - - text: Your regex should match "Hazzah" with 30 z\'s in it. - testString: assert(haRegex.test("Ha" + "z".repeat(30) + "ah"), 'Your regex should match "Hazzah" with 30 z\'s in it.'); + testString: assert("Hazzzzzzah".match(haRegex)[0].length === 10); + - text: Your regex should match "Hazzah" with 30 z's in it. + testString: assert("Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah".match(haRegex)[0].length === 34); ``` @@ -73,7 +73,7 @@ let result = haRegex.test(haStr); ```js let haStr = "Hazzzzah"; -let haRegex = /z{4,}/; // Change this line +let haRegex = /Haz{4,}ah/; // Change this line let result = haRegex.test(haStr); ``` diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md index a1254f78c2..8b36980cc9 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md @@ -7,6 +7,8 @@ The Problem Change the regex haRegex to match the word "Hazzah" only when it has four or more letter z's. Solution +```js let haStr = "Hazzzzah"; -let haRegex = /Haz{4,30}ah/; // Change this line +let haRegex = /Haz{4,}ah/; // Change this line let result = haRegex.test(haStr); +```