* Use dfn tags
* remove misused <dfn> tags
* Revert "remove misused <dfn> tags"
This reverts commit b24968a968.
* Update curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/fill-in-the-blank-with-placeholder-text.english.md
Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
* Make "array" lowercase
Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
* Fix dfn usage
* Address last dfn tags
2.9 KiB
2.9 KiB
id, title, challengeType, forumTopicId
| id | title | challengeType | forumTopicId |
|---|---|---|---|
| 587d7db5367417b2b2512b95 | Match Single Character with Multiple Possibilities | 1 | 301357 |
Description
/literal/) and wildcard character (/./). Those are the extremes of regular expressions, where one finds exact matches and the other matches everything. There are options that are a balance between the two extremes.
You can search for a literal pattern with some flexibility with character classes. Character classes allow you to define a group of characters you wish to match by placing them inside square ([ and ]) brackets.
For example, you want to match "bag", "big", and "bug" but not "bog". You can create the regex /b[aiu]g/ to do this. The [aiu] is the character class that will only match the characters "a", "i", or "u".
let bigStr = "big";
let bagStr = "bag";
let bugStr = "bug";
let bogStr = "bog";
let bgRegex = /b[aiu]g/;
bigStr.match(bgRegex); // Returns ["big"]
bagStr.match(bgRegex); // Returns ["bag"]
bugStr.match(bgRegex); // Returns ["bug"]
bogStr.match(bgRegex); // Returns null
Instructions
a, e, i, o, u) in your regex vowelRegex to find all the vowels in the string quoteSample.
NoteBe sure to match both upper- and lowercase vowels.
Tests
tests:
- text: You should find all 25 vowels.
testString: assert(result.length == 25);
- text: Your regex <code>vowelRegex</code> should use a character class.
testString: assert(/\[.*\]/.test(vowelRegex.source));
- text: Your regex <code>vowelRegex</code> should use the global flag.
testString: assert(vowelRegex.flags.match(/g/).length == 1);
- text: Your regex <code>vowelRegex</code> should use the case insensitive flag.
testString: assert(vowelRegex.flags.match(/i/).length == 1);
- text: Your regex should not match any consonants.
testString: assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()));
Challenge Seed
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /change/; // Change this line
let result = vowelRegex; // Change this line
Solution
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /[aeiou]/gi; // Change this line
let result = quoteSample.match(vowelRegex); // Change this line