-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREGEX_Ignore_Case_While_Matching.js
More file actions
49 lines (31 loc) · 1.39 KB
/
REGEX_Ignore_Case_While_Matching.js
File metadata and controls
49 lines (31 loc) · 1.39 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
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Ignore Case While Matching
Up until now, you've looked at regexes to do literal matches of strings.
But sometimes, you might want to also match case differences.
Case (or sometimes letter case) is the difference between uppercase
letters and lowercase letters.
Examples of uppercase are A, B, and C.
Examples of lowercase are a, b, and c.
You can match both cases using what is called a flag.
There are other flags but here you'll focus on the flag that ignores
case - the i flag.
You can use it by appending it to the regex.
An example of using this flag is /ignorecase/i.
This regex can match the strings ignorecase, igNoreCase, and IgnoreCase.
EXERCISE
Write a regex fccRegex to match freeCodeCamp, no matter its case.
Your regex should not match any abbreviations or variations with spaces.
Your regex should match the string freeCodeCamp
Your regex should match the string FreeCodeCamp
Your regex should match the string FreecodeCamp
Your regex should match the string FreeCodecamp
Your regex should not match the string Free Code Camp
Your regex should match the string FreeCOdeCamp
Your regex should not match the string FCC
Your regex should match the string FrEeCoDeCamp
Your regex should match the string FrEeCodECamp
Your regex should match the string FReeCodeCAmp
*/
let myString = "freeCodeCamp";
let fccRegex = /freeCodeCamp/i; // Change this line
let result = fccRegex.test(myString);