From a3b54d34cbd31a38a00b982e9fef571f0606c2b3 Mon Sep 17 00:00:00 2001 From: Kimon Date: Sat, 25 Apr 2020 14:35:46 +0100 Subject: [PATCH] Differentiate between test & match (#38498) * Differentiate between test & match I noticed that nowhere was there a mention that .match() and .test() pass in and are applied to opposite objects. This would've saved me a few minutes of searching during later challenges that assume this is understood. * Add in .match & .test difference after example * fix: add spaces to stop lint errors Co-authored-by: Oliver Eyton-Williams --- .../regular-expressions/extract-matches.english.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.english.md index f63f387be5..5b7a7dcba6 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.english.md @@ -8,7 +8,8 @@ forumTopicId: 301340 ## Description
So far, you have only been checking if a pattern exists or not within a string. You can also extract the actual matches you found with the .match() method. -To use the .match() method, apply the method on a string and pass in the regex inside the parentheses. Here's an example: +To use the .match() method, apply the method on a string and pass in the regex inside the parentheses. +Here's an example: ```js "Hello, World!".match(/Hello/); @@ -19,6 +20,13 @@ ourStr.match(ourRegex); // Returns ["expressions"] ``` +Note that the `.match` syntax is the "opposite" of the `.test` method you have been using thus far: + +```js +'string'.match(/regex/); +/regex/.test('string'); +``` +
## Instructions