-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREGEX_Match_Literal_Strings.js
More file actions
36 lines (26 loc) · 1.03 KB
/
REGEX_Match_Literal_Strings.js
File metadata and controls
36 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Match Literal Strings
In the last challenge, you searched for the word 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.";
let testRegex = /Kevin/;
testRegex.test(testStr);
This test call will return true.
Any other forms of Kevin will not match.
For example, the regex /Kevin/ will not match kevin or KEVIN.
let wrongRegex = /kevin/;
wrongRegex.test(testStr);
This test call will return false.
A future challenge will show how to match those other forms as well.
EXERCISE
Complete the regex waldoRegex to find "Waldo" in the string waldoIsHiding with a literal match.
Your regex waldoRegex should find the string Waldo
Your regex waldoRegex should not search for anything else.
You should perform a literal string match with your regex.
*/
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
let waldoRegex = /Waldo/;
let result = waldoRegex.test(waldoIsHiding);