.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:
"Hello, World!".match(/Hello/);
// Returns ["Hello"]
let ourStr = "Regular expressions";
let ourRegex = /expressions/;
ourStr.match(ourRegex);
// Returns ["expressions"]
.match()
method to extract the word coding
.
result
should have the word coding
testString: assert(result.join() === "coding", 'The result
should have the word coding
');
- text: Your regex codingRegex
should search for coding
testString: assert(codingRegex.source === "coding", 'Your regex codingRegex
should search for coding
');
- text: You should use the .match()
method.
testString: assert(code.match(/\.match\(.*\)/), 'You should use the .match()
method.');
```