From a987245e1879438c7a457e09e681fbf427d4d834 Mon Sep 17 00:00:00 2001 From: Divyanshu Date: Mon, 25 Nov 2019 03:41:20 +0530 Subject: [PATCH] Added new test cases and corrected the solution for positive and negative lookahead for ensuring that strings beginning with numbers are not accepted (#37485) * Added new test case '8pass99' for positive and negative lookahead * Changed the pwRegex to reflect the new solution * Updated the pwRegex to reflect the latest solution as on forum * Added another test case to catch "/^(?=\w{6,})(?=\D*\d{2})/" solution --- .../positive-and-negative-lookahead.english.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.english.md index 48d3a6e731..8bf4465030 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.english.md @@ -58,6 +58,12 @@ tests: testString: assert(!pwRegex.test("123")); - text: Your regex should not match "1234" testString: assert(!pwRegex.test("1234")); + - text: Your regex should not match "8pass99" + testString: assert(!pwRegex.test("8pass99")); + - text: Your regex should not match "12abcde" + testString: assert(!pwRegex.test("12abcde")); + + ``` @@ -85,7 +91,7 @@ let result = pwRegex.test(sampleWord); ```js -var pwRegex = /(?=\w{6})(?=\D*\d{2})/; +var pwRegex = /^(?=\w{6})(?=\D+\d{2})/; ```