2018-10-10 18:03:03 -04:00
---
id: 587d7db4367417b2b2512b91
2021-02-06 04:42:36 +00:00
title: Ignore Case While Matching
2018-10-10 18:03:03 -04:00
challengeType: 1
2020-08-04 15:14:01 +08:00
forumTopicId: 301344
2021-01-13 03:31:00 +01:00
dashedName: ignore-case-while-matching
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2021-02-06 04:42:36 +00:00
Up until now, you've looked at regexes to do literal matches of strings. But sometimes, you might want to also match case differences.
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
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"` .
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
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"` .
2020-12-16 00:37:30 -07:00
# --instructions--
2021-02-06 04:42:36 +00:00
Write a regex `fccRegex` to match `"freeCodeCamp"` , no matter its case. Your regex should not match any abbreviations or variations with spaces.
2020-12-16 00:37:30 -07:00
# --hints--
2021-02-06 04:42:36 +00:00
Your regex should match `freeCodeCamp`
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('freeCodeCamp'));
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
Your regex should match `FreeCodeCamp`
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('FreeCodeCamp'));
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should match `FreecodeCamp`
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(fccRegex.test('FreecodeCamp'));
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
Your regex should match `FreeCodecamp`
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('FreeCodecamp'));
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should not match `Free Code Camp`
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(!fccRegex.test('Free Code Camp'));
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should match `FreeCOdeCamp`
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(fccRegex.test('FreeCOdeCamp'));
2018-10-10 18:03:03 -04:00
```
2020-08-04 15:14:01 +08:00
2021-02-06 04:42:36 +00:00
Your regex should not match `FCC`
2020-12-16 00:37:30 -07:00
```js
assert(!fccRegex.test('FCC'));
```
2021-02-06 04:42:36 +00:00
Your regex should match `FrEeCoDeCamp`
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('FrEeCoDeCamp'));
```
2021-02-06 04:42:36 +00:00
Your regex should match `FrEeCodECamp`
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('FrEeCodECamp'));
```
2021-02-06 04:42:36 +00:00
Your regex should match `FReeCodeCAmp`
2020-12-16 00:37:30 -07:00
```js
assert(fccRegex.test('FReeCodeCAmp'));
```
2021-01-13 03:31:00 +01:00
# --seed--
## --seed-contents--
```js
let myString = "freeCodeCamp";
let fccRegex = /change/; // Change this line
let result = fccRegex.test(myString);
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
let myString = "freeCodeCamp";
let fccRegex = /freecodecamp/i; // Change this line
let result = fccRegex.test(myString);
```