"Hello" using the regular expression /Hello/. That regex searched for a literal match of the string "Hello". Here's another example searching for a literal match of the string "Kevin":
let testStr = "Hello, my name is Kevin.";Any other forms of
let testRegex = /Kevin/;
testRegex.test(testStr);
// Returns true
"Kevin" will not match. For example, the regex /Kevin/ will not match "kevin" or "KEVIN".
let wrongRegex = /kevin/;A future challenge will show how to match those other forms as well.
wrongRegex.test(testStr);
// Returns false
waldoRegex to find "Waldo" in the string waldoIsHiding with a literal match.
waldoRegex should find "Waldo"
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex waldoRegex should find "Waldo"");'
- text: Your regex waldoRegex should not search for anything else.
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex waldoRegex should not search for anything else.");'
- text: You should perform a literal string match with your regex.
testString: 'assert(!/\/.*\/i/.test(code), "You should perform a literal string match with your regex.");'
```