From cf82a2b33e98763b65832e69eb5bcfc11b36ca57 Mon Sep 17 00:00:00 2001 From: Yasmin Yazdi Date: Mon, 31 Aug 2020 06:29:42 -0500 Subject: [PATCH] fix global flag fail in Regex by resetting last Index (#39457) * fixing global flag fail by resetting last index. Issue #37890 * fixed syntax error * making requested changes --- ...atch-anything-with-wildcard-period.english.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.english.md index 0a46ce9b96..605cd097b1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.english.md @@ -36,21 +36,21 @@ tests: - text: You should use the wildcard character in your regex unRegex testString: assert(/\./.test(unRegex.source)); - text: Your regex unRegex should match "run" in "Let us go on a run." - testString: assert(unRegex.test("Let us go on a run.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("Let us go on a run.")); - text: Your regex unRegex should match "sun" in "The sun is out today." - testString: assert(unRegex.test("The sun is out today.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("The sun is out today.")); - text: Your regex unRegex should match "fun" in "Coding is a lot of fun." - testString: assert(unRegex.test("Coding is a lot of fun.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("Coding is a lot of fun.")); - text: Your regex unRegex should match "pun" in "Seven days without a pun makes one weak." - testString: assert(unRegex.test("Seven days without a pun makes one weak.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("Seven days without a pun makes one weak.")); - text: Your regex unRegex should match "nun" in "One takes a vow to be a nun." - testString: assert(unRegex.test("One takes a vow to be a nun.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("One takes a vow to be a nun.")); - text: Your regex unRegex should match "bun" in "She got fired from the hot dog stand for putting her hair in a bun." - testString: assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun.")); + testString: unRegex.lastIndex = 0; assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun.")); - text: Your regex unRegex should not match "There is a bug in my code." - testString: assert(!unRegex.test("There is a bug in my code.")); + testString: unRegex.lastIndex = 0; assert(!unRegex.test("There is a bug in my code.")); - text: Your regex unRegex should not match "Catch me if you can." - testString: assert(!unRegex.test("Can me if you can.")); + testString: unRegex.lastIndex = 0; assert(!unRegex.test("Catch me if you can.")); ```