Files
.github
api-server
client
config
curriculum
__fixtures__
challenges
_meta
arabic
chinese
english
01-responsive-web-design
02-javascript-algorithms-and-data-structures
basic-algorithm-scripting
basic-data-structures
basic-javascript
debugging
es6
functional-programming
intermediate-algorithm-scripting
javascript-algorithms-and-data-structures-projects
object-oriented-programming
regular-expressions
check-for-all-or-none.english.md
check-for-mixed-grouping-of-characters.english.md
extract-matches.english.md
find-characters-with-lazy-matching.english.md
find-more-than-the-first-match.english.md
find-one-or-more-criminals-in-a-hunt.english.md
ignore-case-while-matching.english.md
match-a-literal-string-with-different-possibilities.english.md
match-all-letters-and-numbers.english.md
match-all-non-numbers.english.md
match-all-numbers.english.md
match-anything-with-wildcard-period.english.md
match-beginning-string-patterns.english.md
match-characters-that-occur-one-or-more-times.english.md
match-characters-that-occur-zero-or-more-times.english.md
match-ending-string-patterns.english.md
match-everything-but-letters-and-numbers.english.md
match-letters-of-the-alphabet.english.md
match-literal-strings.english.md
match-non-whitespace-characters.english.md
match-numbers-and-letters-of-the-alphabet.english.md
match-single-character-with-multiple-possibilities.english.md
match-single-characters-not-specified.english.md
match-whitespace.english.md
positive-and-negative-lookahead.english.md
remove-whitespace-from-start-and-end.english.md
restrict-possible-usernames.english.md
reuse-patterns-using-capture-groups.english.md
specify-exact-number-of-matches.english.md
specify-only-the-lower-number-of-matches.english.md
specify-upper-and-lower-number-of-matches.english.md
use-capture-groups-to-search-and-replace.english.md
using-the-test-method.english.md
03-front-end-libraries
04-data-visualization
05-apis-and-microservices
06-quality-assurance
07-scientific-computing-with-python
08-data-analysis-with-python
09-information-security
10-coding-interview-prep
11-machine-learning-with-python
12-certificates
portuguese
russian
spanish
schema
test
.babelrc
.editorconfig
.npmignore
.travis.yml
CHANGELOG.md
LICENSE.md
comment-dictionary.js
commitizen.config.js
commitlint.config.js
create-challenge-bundle.js
getChallenges.acceptance.test.js
getChallenges.js
getChallenges.test.js
gulpfile.js
lib.js
package-entry.js
package-lock.json
package.json
utils.js
cypress
docs
tools
utils
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.gitpod.yml
.node-inspectorrc
.npmrc
.prettierignore
.prettierrc
.snyk
.vcmrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile.tests
HoF.md
LICENSE.md
README.md
SECURITY.md
change_volumes_owner.sh
crowdin.yml
cypress-install.js
cypress.json
docker-compose-shared.yml
docker-compose.tests.yml
docker-compose.yml
jest.config.js
lerna.json
lighthouserc.js
package-lock.json
package.json
sample.env

77 lines
2.7 KiB
Markdown
Raw Normal View History

---
id: 587d7db4367417b2b2512b91
title: Ignore Case While Matching
challengeType: 1
forumTopicId: 301344
---
## Description
<section id='description'>
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 <code>"A"</code>, <code>"B"</code>, and <code>"C"</code>. Examples of lowercase are <code>"a"</code>, <code>"b"</code>, and <code>"c"</code>.
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 <code>i</code> flag. You can use it by appending it to the regex. An example of using this flag is <code>/ignorecase/i</code>. This regex can match the strings <code>"ignorecase"</code>, <code>"igNoreCase"</code>, and <code>"IgnoreCase"</code>.
</section>
## Instructions
<section id='instructions'>
Write a regex <code>fccRegex</code> to match <code>"freeCodeCamp"</code>, no matter its case. Your regex should not match any abbreviations or variations with spaces.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your regex should match <code>freeCodeCamp</code>
testString: assert(fccRegex.test('freeCodeCamp'));
- text: Your regex should match <code>FreeCodeCamp</code>
testString: assert(fccRegex.test('FreeCodeCamp'));
- text: Your regex should match <code>FreecodeCamp</code>
testString: assert(fccRegex.test('FreecodeCamp'));
- text: Your regex should match <code>FreeCodecamp</code>
testString: assert(fccRegex.test('FreeCodecamp'));
- text: Your regex should not match <code>Free Code Camp</code>
testString: assert(!fccRegex.test('Free Code Camp'));
- text: Your regex should match <code>FreeCOdeCamp</code>
testString: assert(fccRegex.test('FreeCOdeCamp'));
- text: Your regex should not match <code>FCC</code>
testString: assert(!fccRegex.test('FCC'));
- text: Your regex should match <code>FrEeCoDeCamp</code>
testString: assert(fccRegex.test('FrEeCoDeCamp'));
- text: Your regex should match <code>FrEeCodECamp</code>
testString: assert(fccRegex.test('FrEeCodECamp'));
- text: Your regex should match <code>FReeCodeCAmp</code>
testString: assert(fccRegex.test('FReeCodeCAmp'));
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let myString = "freeCodeCamp";
let fccRegex = /change/; // Change this line
let result = fccRegex.test(myString);
```
</div>
</section>
## Solution
<section id='solution'>
```js
let myString = "freeCodeCamp";
let fccRegex = /freecodecamp/i; // Change this line
let result = fccRegex.test(myString);
```
</section>