{
  "name": "Regular Expressions",
  "order": 3,
  "time": "5 hours",
  "helpRoom": "Help",
  "challenges": [
    {
      "id": "587d7db3367417b2b2512b8d",
      "title": "Introduction to the Regular Expression Challenges",
      "description": [
        [
          "https://camo.githubusercontent.com/85ac1a6783961ce77add6b2e8630dbf6521d33b2/687474703a2f2f696d67732e786b63642e636f6d2f636f6d6963732f726567756c61725f65787072657373696f6e732e706e67",
          "XKCD web comic showing how regular expressions can save the day",
          "Regular expressions are special strings that represent a search pattern. Also known as \"regex\" or \"regexp\", they help programmers match, search, and replace text. Regular expressions can appear cryptic because a few characters have special meaning. The goal is to combine the symbols and text into a pattern that matches what you want, but only what you want. This section will cover the characters, a few shortcuts, and the common uses for writing regular expressions.",
          ""
        ]
      ],
      "releasedOn": "Feb 17, 2017",
      "challengeSeed": [],
      "tests": [],
      "type": "waypoint",
      "challengeType": 7,
      "isRequired": false,
      "translations": {}
    },
    {
      "id": "587d7db3367417b2b2512b8e",
      "title": "Using the Test Method",
      "description": [
        "Regular expressions are used in programming languages to match parts of strings. You create patterns to help you do that matching.",
        "If you want to find the word <code>\"the\"</code> in the string <code>\"The dog chased the cat\"</code>, you could use the following regular expression: <code>/the/</code>. Notice that quote marks are not required within the regular expression.",
        "JavaScript has multiple ways to use regexes. One way to test a regex is using the <code>.test()</code> method. The <code>.test()</code> method takes the regex, applies it to a string (which is placed inside the parentheses), and returns <code>true</code> or <code>false</code> if your pattern finds something or not.",
        "<blockquote>let testStr = \"freeCodeCamp\";<br>let testRegex = /Code/;<br>testRegex.test(testStr);<br>// Returns true</blockquote>",
        "<hr>",
        "Apply the regex <code>myRegex</code> on the string <code>myString</code> using the <code>.test()</code> method."
      ],
      "challengeSeed": [
        "let myString = \"Hello, World!\";",
        "let myRegex = /Hello/;",
        "let result = myRegex; // Change this line"
      ],
      "tests": [
        "assert(code.match(/myRegex.test\\(\\s*myString\\s*\\)/), 'message: You should use <code>.test()</code> to test the regex.');",
        "assert(result === true, 'message: Your result should return <code>true</code>.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db3367417b2b2512b8f",
      "title": "Match Literal Strings",
      "description": [
        "In the last challenge, you searched for the word <code>\"Hello\"</code> using the regular expression <code>/Hello/</code>. That regex searched for a literal match of the string <code>\"Hello\"</code>. Here's another example searching for a literal match of the string <code>\"Kevin\"</code>:",
        "<blockquote>let testStr = \"Hello, my name is Kevin.\";<br>let testRegex = /Kevin/;<br>testRegex.test(testStr);<br>// Returns true</blockquote>",
        "Any other forms of <code>\"Kevin\"</code> will not match. For example, the regex <code>/Kevin/</code> will not match <code>\"kevin\"</code> or <code>\"KEVIN\"</code>.",
        "<blockquote>let wrongRegex = /kevin/;<br>wrongRegex.test(testStr);<br>// Returns false</blockquote>",
        "A future challenge will show how to match those other forms as well.",
        "<hr>",
        "Complete the regex <code>waldoRegex</code> to find <code>\"Waldo\"</code> in the string <code>waldoIsHiding</code> with a literal match."
      ],
      "challengeSeed": [
        "let waldoIsHiding = \"Somewhere Waldo is hiding in this text.\";",
        "let waldoRegex = /search/; // Change this line",
        "let result = waldoRegex.test(waldoIsHiding);"
      ],
      "tests": [
        "assert(waldoRegex.test(waldoIsHiding), 'message: Your regex <code>waldoRegex</code> should find <code>\"Waldo\"</code>');",
        "assert(!waldoRegex.test('Somewhere is hiding in this text.'), 'message: Your regex <code>waldoRegex</code> should not search for anything else.');",
        "assert(!/\\/.*\\/i/.test(code), 'message: You should perform a literal string match with your regex.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db4367417b2b2512b90",
      "title": "Match a Literal String with Different Possibilities",
      "description": [
        "Using regexes like <code>/coding/</code>, you can look for the pattern <code>\"coding\"</code> in another string.",
        "This is powerful to search single strings, but it's limited to only one pattern. You can search for multiple patterns using the <code>alternation</code> or <code>OR</code> operator: <code>|</code>.",
        "This operator matches patterns either before or after it. For example, if you wanted to match <code>\"yes\"</code> or <code>\"no\"</code>, the regex you want is <code>/yes|no/</code>.",
        "You can also search for more than just two patterns. You can do this by adding more patterns with more <code>OR</code> operators separating them, like <code>/yes|no|maybe/</code>.",
        "<hr>",
        "Complete the regex <code>petRegex</code> to match the pets <code>\"dog\"</code>, <code>\"cat\"</code>, <code>\"bird\"</code>, or <code>\"fish\"</code>."
      ],
      "challengeSeed": [
        "let petString = \"James has a pet cat.\";",
        "let petRegex = /change/; // Change this line",
        "let result = petRegex.test(petString);"
      ],
      "tests": [
        "assert(petRegex.test('John has a pet dog.'), 'message: Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"John has a pet dog.\"</code>');",
        "assert(!petRegex.test('Emma has a pet rock.'), 'message: Your regex <code>petRegex</code> should return <code>false</code> for the string <code>\"Emma has a pet rock.\"</code>');",
        "assert(petRegex.test('Emma has a pet bird.'), 'message: Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"Emma has a pet bird.\"</code>');",
        "assert(petRegex.test('Liz has a pet cat.'), 'message: Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"Liz has a pet cat.\"</code>');",
        "assert(!petRegex.test('Kara has a pet dolphin.'), 'message: Your regex <code>petRegex</code> should return <code>false</code> for the string <code>\"Kara has a pet dolphin.\"</code>');",
        "assert(petRegex.test('Alice has a pet fish.'), 'message: Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"Alice has a pet fish.\"</code>');",
        "assert(!petRegex.test('Jimmy has a pet computer.'), 'message: Your regex <code>petRegex</code> should return <code>false</code> for the string <code>\"Jimmy has a pet computer.\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db4367417b2b2512b91",
      "title": "Ignore Case While Matching",
      "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>.",
        "<hr>",
        "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."
      ],
      "challengeSeed": [
        "let myString = \"freeCodeCamp\";",
        "let fccRegex = /change/; // Change this line",
        "let result = fccRegex.test(myString);"
      ],
      "tests": [
        "assert(fccRegex.test('freeCodeCamp'), 'message: Your regex should match <code>freeCodeCamp</code>');",
        "assert(fccRegex.test('FreeCodeCamp'), 'message: Your regex should match <code>FreeCodeCamp</code>');",
        "assert(fccRegex.test('FreecodeCamp'), 'message: Your regex should match <code>FreecodeCamp</code>');",
        "assert(fccRegex.test('FreeCodecamp'), 'message: Your regex should match <code>FreeCodecamp</code>');",
        "assert(!fccRegex.test('Free Code Camp'), 'message: Your regex should not match <code>Free Code Camp</code>');",
        "assert(fccRegex.test('FreeCOdeCamp'), 'message: Your regex should match <code>FreeCOdeCamp</code>');",
        "assert(!fccRegex.test('FCC'), 'message: Your regex should not match <code>FCC</code>');",
        "assert(fccRegex.test('FrEeCoDeCamp'), 'message: Your regex should match <code>FrEeCoDeCamp</code>');",
        "assert(fccRegex.test('FrEeCodECamp'), 'message: Your regex should match <code>FrEeCodECamp</code>');",
        "assert(fccRegex.test('FReeCodeCAmp'), 'message: Your regex should match <code>FReeCodeCAmp</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db4367417b2b2512b92",
      "title": "Extract Matches",
      "description": [
        "So far, you have only been checking if a pattern exists or not within a string. You can also extract the actual matches you found with the <code>.match()</code> method.",
        "To use the <code>.match()</code> method, apply the method on a string and pass in the regex inside the parentheses. Here's an example:",
        "<blockquote>\"Hello, World!\".match(/Hello/);<br>// Returns [\"Hello\"]<br>let ourStr = \"Regular expressions\";<br>let ourRegex = /expressions/;<br>ourStr.match(ourRegex);<br>// Returns [\"expressions\"]</blockquote>",
        "<hr>",
        "Apply the <code>.match()</code> method to extract the word <code>coding</code>."
      ],
      "challengeSeed": [
        "let extractStr = \"Extract the word 'coding' from this string.\";",
        "let codingRegex = /change/; // Change this line",
        "let result = extractStr; // Change this line"
      ],
      "tests": [
        "assert(result.join() === \"coding\", 'message: The <code>result</code> should have the word <code>coding</code>');",
        "assert(codingRegex.source === \"coding\", 'message: Your regex <code>codingRegex</code> should search for <code>coding</code>');",
        "assert(code.match(/\\.match\\(.*\\)/), 'message: You should use the <code>.match()</code> method.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db4367417b2b2512b93",
      "title": "Find More Than the First Match",
      "description": [
        "So far, you have only been able to extract or search a pattern once.",
        "<blockquote>let testStr = \"Repeat, Repeat, Repeat\";<br>let ourRegex = /Repeat/;<br>testStr.match(ourRegex);<br>// Returns [\"Repeat\"]</blockquote>",
        "To search or extract a pattern more than once, you can use the <code>g</code> flag.",
        "<blockquote>let repeatRegex = /Repeat/g;<br>testStr.match(repeatRegex);<br>// Returns [\"Repeat\", \"Repeat\", \"Repeat\"]</blockquote>",
        "<hr>",
        "Using the regex <code>starRegex</code>, find and extract both <code>\"Twinkle\"</code> words from the string <code>twinkleStar</code>.",
        "<strong>Note</strong><br>You can have multiple flags on your regex like <code>/search/gi</code>"
      ],
      "challengeSeed": [
        "let twinkleStar = \"Twinkle, twinkle, little star\";",
        "let starRegex = /change/; // Change this line",
        "let result = twinkleStar; // Change this line"
      ],
      "tests": [
        "assert(starRegex.flags.match(/g/).length == 1, 'message: Your regex <code>starRegex</code> should use the global flag <code>g</code>');",
        "assert(starRegex.flags.match(/i/).length == 1, 'message: Your regex <code>starRegex</code> should use the case insensitive flag <code>i</code>');",
        "assert(result.sort().join() == twinkleStar.match(/twinkle/gi).sort().join(), 'message: Your match should match both occurrences of the word <code>\"Twinkle\"</code>');",
        "assert(result.length == 2, 'message: Your match <code>result</code> should have two elements in it.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db5367417b2b2512b94",
      "title": "Match Anything with Wildcard Period",
      "description": [
        "Sometimes you won't (or don't need to) know the exact characters in your patterns. Thinking of all words that match, say, a misspelling would take a long time. Luckily, you can save time using the wildcard character: <code>.</code>",
        "The wildcard character <code>.</code> will match any one character. The wildcard is also called <code>dot</code> and <code>period</code>. You can use the wildcard character just like any other character in the regex. For example, if you wanted to match <code>\"hug\"</code>, <code>\"huh\"</code>, <code>\"hut\"</code>, and <code>\"hum\"</code>, you can use the regex <code>/hu./</code> to match all four words.",
        "<blockquote>let humStr = \"I'll hum a song\";<br>let hugStr = \"Bear hug\";<br>let huRegex = /hu./;<br>humStr.match(huRegex); // Returns [\"hum\"]<br>hugStr.match(huRegex); // Returns [\"hug\"]</blockquote>",
        "<hr>",
        "Complete the regex <code>unRegex</code> so that it matches the strings <code>\"run\"</code>, <code>\"sun\"</code>, <code>\"fun\"</code>, <code>\"pun\"</code>, <code>\"nun\"</code>, and <code>\"bun\"</code>. Your regex should use the wildcard character."
      ],
      "challengeSeed": [
        "let exampleStr = \"Let's have fun with regular expressions!\";",
        "let unRegex = /change/; // Change this line",
        "let result = unRegex.test(exampleStr);"
      ],
      "tests": [
        "assert(code.match(/\\.test\\(.*\\)/), 'message: You should use the <code>.test()</code> method.');",
        "assert(/\\./.test(unRegex.source), 'message: You should use the wildcard character in your regex <code>unRegex</code>');",
        "assert(unRegex.test(\"Let us go on a run.\"), 'message: Your regex <code>unRegex</code> should match <code>\"run\"</code> in <code>\"Let us go on a run.\"</code>');",
        "assert(unRegex.test(\"The sun is out today.\"), 'message: Your regex <code>unRegex</code> should match <code>\"sun\"</code> in <code>\"The sun is out today.\"</code>');",
        "assert(unRegex.test(\"Coding is a lot of fun.\"), 'message: Your regex <code>unRegex</code> should match <code>\"fun\"</code> in <code>\"Coding is a lot of fun.\"</code>');",
        "assert(unRegex.test(\"Seven days without a pun makes one weak.\"), 'message: Your regex <code>unRegex</code> should match <code>\"pun\"</code> in <code>\"Seven days without a pun makes one weak.\"</code>');",
        "assert(unRegex.test(\"One takes a vow to be a nun.\"), 'message: Your regex <code>unRegex</code> should match <code>\"nun\"</code> in <code>\"One takes a vow to be a nun.\"</code>');",
        "assert(unRegex.test(\"She got fired from the hot dog stand for putting her hair in a bun.\"), 'message: Your regex <code>unRegex</code> should match <code>\"bun\"</code> in <code>\"She got fired from the hot dog stand for putting her hair in a bun.\"</code>');",
        "assert(!unRegex.test(\"There is a bug in my code.\"), 'message: Your regex <code>unRegex</code> should not match <code>\"There is a bug in my code.\"</code>');",
        "assert(!unRegex.test(\"Can me if you can.\"), 'message: Your regex <code>unRegex</code> should not match <code>\"Catch me if you can.\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db5367417b2b2512b95",
      "title": "Match Single Character with Multiple Possibilities",
      "description": [
        "You learned how to match literal patterns (<code>/literal/</code>) and wildcard character (<code>/./</code>). 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 <code>character classes</code>. Character classes allow you to define a group of characters you wish to match by placing them inside square (<code>[</code> and <code>]</code>) brackets.",
        "For example, you want to match <code>\"bag\"</code>, <code>\"big\"</code>, and <code>\"bug\"</code> but not <code>\"bog\"</code>. You can create the regex <code>/b[aiu]g/</code> to do this. The <code>[aiu]</code> is the character class that will only match the characters <code>\"a\"</code>, <code>\"i\"</code>, or <code>\"u\"</code>.",
        "<blockquote>let bigStr = \"big\";<br>let bagStr = \"bag\";<br>let bugStr = \"bug\";<br>let bogStr = \"bog\";<br>let bgRegex = /b[aiu]g/;<br>bigStr.match(bgRegex); // Returns [\"big\"]<br>bagStr.match(bgRegex); // Returns [\"bag\"]<br>bugStr.match(bgRegex); // Returns [\"bug\"]<br>bogStr.match(bgRegex); // Returns null</blockquote>",
        "<hr>",
        "Use a character class with vowels (<code>a</code>, <code>e</code>, <code>i</code>, <code>o</code>, <code>u</code>) in your regex <code>vowelRegex</code> to find all the vowels in the string <code>quoteSample</code>.",
        "<strong>Note</strong><br>Be sure to match both upper- and lowercase vowels."
      ],
      "challengeSeed": [
        "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"
      ],
      "tests": [
        "assert(result.length == 25, 'message: You should find all 25 vowels.');",
        "assert(/\\[.*\\]/.test(vowelRegex.source), 'message: Your regex <code>vowelRegex</code> should use a character class.');",
        "assert(vowelRegex.flags.match(/g/).length == 1, 'message: Your regex <code>vowelRegex</code> should use the global flag.');",
        "assert(vowelRegex.flags.match(/i/).length == 1, 'message: Your regex <code>vowelRegex</code> should use the case insensitive flag.');",
        "assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()), 'message: Your regex should not match any consonants.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db5367417b2b2512b96",
      "title": "Match Letters of the Alphabet",
      "description": [
        "You saw how you can use <code>character sets</code> to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple.",
        "Inside a <code>character set</code>, you can define a range of characters to match using a <code>hyphen</code> character: <code>-</code>.",
        "For example, to match lowercase letters <code>a</code> through <code>e</code> you would use <code>[a-e]</code>.",
        "<blockquote>let catStr = \"cat\";<br>let batStr = \"bat\";<br>let matStr = \"mat\";<br>let bgRegex = /[a-e]at/;<br>catStr.match(bgRegex); // Returns [\"cat\"]<br>batStr.match(bgRegex); // Returns [\"bat\"]<br>matStr.match(bgRegex); // Returns null</blockquote>",
        "<hr>",
        "Match all the letters in the string <code>quoteSample</code>.",
        "<strong>Note</strong><br>Be sure to match both upper- and lowercase vowels."
      ],
      "challengeSeed": [
        "let quoteSample = \"The quick brown fox jumps over the lazy dog.\";",
        "let alphabetRegex = /change/; // Change this line",
        "let result = alphabetRegex; // Change this line"
      ],
      "tests": [
        "assert(result.length == 35, 'message: Your regex <code>alphabetRegex</code> should match 35 items.');",
        "assert(alphabetRegex.flags.match(/g/).length == 1, 'message: Your regex <code>alphabetRegex</code> should use the global flag.');",
        "assert(alphabetRegex.flags.match(/i/).length == 1, 'message: Your regex <code>alphabetRegex</code> should use the case insensitive flag.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db5367417b2b2512b97",
      "title": "Match Numbers and Letters of the Alphabet",
      "description": [
        "Using the hyphen (<code>-</code>) to match a range of characters is not limited to letters. It also works to match a range of numbers.",
        "For example, <code>/[0-5]/</code> matches any number between <code>0</code> and <code>5</code>, including the <code>0</code> and <code>5</code>.",
        "Also, it is possible to combine a range of letters and numbers in a single character set.",
        "<blockquote>let jennyStr = \"Jenny8675309\";<br>let myRegex = /[a-z0-9]/ig;<br>// matches all letters and numbers in jennyStr<br>jennyStr.match(myRegex);</blockquote>",
        "<hr>",
        "Create a single regex that matches a range of letters between <code>h</code> and <code>s</code>, and a range of numbers between <code>2</code> and <code>6</code>. Remember to include the appropriate flags in the regex."
      ],
      "challengeSeed": [
        "let quoteSample = \"Blueberry 3.141592653s are delicious.\";",
        "let myRegex = /change/; // Change this line",
        "let result = myRegex; // Change this line"
      ],
      "tests": [
        "assert(result.length == 17, 'message: Your regex <code>myRegex</code> should match 17 items.');",
        "assert(myRegex.flags.match(/g/).length == 1, 'message: Your regex <code>myRegex</code> should use the global flag.');",
        "assert(myRegex.flags.match(/i/).length == 1, 'message: Your regex <code>myRegex</code> should use the case insensitive flag.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db6367417b2b2512b98",
      "title": "Match Single Characters Not Specified",
      "description": [
        "So far, you have created a set of characters that you want to match, but you could also create a set of characters that you do not want to match. These types of character sets are called <code>negated character sets</code>.",
        "To create a <code>negated character set</code>, you place a <code>caret</code> character (<code>^</code>) after the opening bracket and before the characters you do not want to match.",
        "For example, <code>/[^aeiou]/gi</code> matches all characters that are not a vowel. Note that characters like <code>.</code>, <code>!</code>, <code>[</code>, <code>@</code>, <code>/</code> and white space are matched - the negated vowel character set only excludes the vowel characters.",
        "<hr>",
        "Create a single regex that matches all characters that are not a number or a vowel. Remember to include the appropriate flags in the regex."
      ],
      "challengeSeed": [
        "let quoteSample = \"3 blind mice.\";",
        "let myRegex = /change/; // Change this line",
        "let result = myRegex; // Change this line"
      ],
      "tests": [
        "assert(result.length == 9, 'message: Your regex <code>myRegex</code> should match 9 items.');",
        "assert(myRegex.flags.match(/g/).length == 1, 'message: Your regex <code>myRegex</code> should use the global flag.');",
        "assert(myRegex.flags.match(/i/).length == 1, 'message: Your regex <code>myRegex</code> should use the case insensitive flag.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db6367417b2b2512b99",
      "title": "Match Characters that Occur One or More Times",
      "description": [
        "Sometimes, you need to match a character (or group of characters) that appears one or more times in a row. This means it occurs at least once, and may be repeated.",
        "You can use the <code>+</code> character to check if that is the case. Remember, the character or pattern has to be present consecutively. That is, the character has to repeat one after the other.",
        "For example, <code>/a+/g</code> would find one match in <code>\"abc\"</code> and return <code>[\"a\"]</code>. Because of the <code>+</code>, it would also find a single match in <code>\"aabc\"</code> and return <code>[\"aa\"]</code>.",
        "If it were instead checking the string <code>\"abab\"</code>, it would find two matches and return <code>[\"a\", \"a\"]</code> because the <code>a</code> characters are not in a row - there is a <code>b</code> between them. Finally, since there is no <code>\"a\"</code> in the string <code>\"bcd\"</code>, it wouldn't find a match.",
        "<hr>",
        "You want to find matches when the letter <code>s</code> occurs one or more times in <code>\"Mississippi\"</code>. Write a regex that uses the <code>+</code> sign."
      ],
      "challengeSeed": [
        "let difficultSpelling = \"Mississippi\";",
        "let myRegex = /change/; // Change this line",
        "let result = difficultSpelling.match(myRegex);"
      ],
      "tests": [
        "assert(/\\+/.test(myRegex.source), 'message: Your regex <code>myRegex</code> should use the <code>+</code> sign to match one or more <code>s</code> characters.');",
        "assert(result.length == 2, 'message: Your regex <code>myRegex</code> should match 2 items.');",
        "assert(result[0] == 'ss' && result[1] == 'ss', 'message: The <code>result</code> variable should be an array with two matches of <code>\"ss\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db6367417b2b2512b9a",
      "title": "Match Characters that Occur Zero or More Times",
      "description": [
        "The last challenge used the plus <code>+</code> sign to look for characters that occur one or more times. There's also an option that matches characters that occur zero or more times.",
        "The character to do this is the <code>asterisk</code> or <code>star</code>: <code>*</code>.",
        "<blockquote>let soccerWord = \"gooooooooal!\";<br>let gPhrase = \"gut feeling\";<br>let oPhrase = \"over the moon\";<br>let goRegex = /go*/;<br>soccerWord.match(goRegex); // Returns [\"goooooooo\"]<br>gPhrase.match(goRegex); // Returns [\"g\"]<br>oPhrase.match(goRegex); // Returns null</blockquote>",
        "<hr>",
        "Create a regex <code>chewieRegex</code> that uses the <code>*</code> character to match all the upper and lower<code>\"a\"</code> characters in <code>chewieQuote</code>. Your regex does not need flags, and it should not match any of the other quotes."
      ],
      "challengeSeed": [
        "let chewieQuote = \"Aaaaaaaaaaaaaaaarrrgh!\";",
        "let chewieRegex = /change/; // Change this line",
        "let result = chewieQuote.match(chewieRegex);"
      ],
      "tests": [
        "assert(/\\*/.test(chewieRegex.source), 'message: Your regex <code>chewieRegex</code> should use the <code>*</code> character to match zero or more <code>a</code> characters.');",
        "assert(result[0].length === 16, 'message: Your regex <code>chewieRegex</code> should match 16 characters.');",
        "assert(result[0] === 'Aaaaaaaaaaaaaaaa', 'message: Your regex should match <code>\"Aaaaaaaaaaaaaaaa\"</code>.');",
        "assert(!\"He made a fair move. Screaming about it can\\'t help you.\".match(chewieRegex), 'message: Your regex should not match any characters in <code>\"He made a fair move. Screaming about it can&#39t help you.\"</code>');",
        "assert(!\"Let him have it. It\\'s not wise to upset a Wookiee.\".match(chewieRegex), 'message: Your regex should not match any characters in <code>\"Let him have it. It&#39s not wise to upset a Wookiee.\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db6367417b2b2512b9b",
      "title": "Find Characters with Lazy Matching",
      "description": [
        "In regular expressions, a <code>greedy</code> match finds the longest possible part of a string that fits the regex pattern and returns it as a match. The alternative is called a <code>lazy</code> match, which finds the smallest possible part of the string that satisfies the regex pattern.",
        "You can apply the regex <code>/t[a-z]*i/</code> to the string <code>\"titanic\"</code>. This regex is basically a pattern that starts with <code>t</code>, ends with <code>i</code>, and has some letters in between.",
        "Regular expressions are by default <code>greedy</code>, so the match would return <code>[\"titani\"]</code>. It finds the largest sub-string possible to fit the pattern.",
        "However, you can use the <code>?</code> character to change it to <code>lazy</code> matching. <code>\"titanic\"</code> matched against the adjusted regex of <code>/t[a-z]*?i/</code> returns <code>[\"ti\"]</code>.",
        "<hr>",
        "Fix the regex <code>/&lt;.*&gt;/</code> to return the HTML tag <code>&lt;h1&gt;</code> and not the text <code>\"&lt;h1&gt;Winter is coming&lt;/h1&gt;\"</code>. Remember the wildcard <code>.</code> in a regular expression matches any character."
      ],
      "challengeSeed": [
        "let text = \"<h1>Winter is coming</h1>\";",
        "let myRegex = /<.*>/; // Change this line",
        "let result = text.match(myRegex);"
      ],
      "tests": [
        "assert(result[0] == '<h1>', 'message: The <code>result</code> variable should be an array with <code>&lt;h1&gt;</code> in it');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db7367417b2b2512b9c",
      "title": "Find One or More Criminals in a Hunt",
      "description": [
        "Time to pause and test your new regex writing skills. A group of criminals escaped from jail and ran away, but you don't know how many. However, you do know that they stay close together when they are around other people. You are responsible for finding all of the criminals at once.",
        "Here's an example to review how to do this:",
        "The regex <code>/z+/</code> matches the letter <code>z</code> when it appears one or more times in a row. It would find matches in all of the following strings:",
        "<blockquote>\"z\"<br>\"zzzzzz\"<br>\"ABCzzzz\"<br>\"zzzzABC\"<br>\"abczzzzzzzzzzzzzzzzzzzzzabc\"</blockquote>",
        "But it does not find matches in the following strings since there are no letter <code>z</code> characters:",
        "<blockquote>\"\"<br>\"ABC\"<br>\"abcabc\"</blockquote>",
        "<hr>",
        "Write a <code>greedy</code> regex that finds one or more criminals within a group of other people. A criminal is represented by the capital letter <code>C</code>."
      ],
      "challengeSeed": [
        "// example crowd gathering",
        "let crowd = 'P1P2P3P4P5P6CCCP7P8P9';",
        "",
        "let reCriminals = /./; // Change this line",
        "",
        "let matchedCriminals = crowd.match(reCriminals);",
        "console.log(matchedCriminals);"
      ],
      "tests": [
        "assert('C'.match(reCriminals) && 'C'.match(reCriminals)[0] == 'C', 'message: Your regex should match <em>one</em> criminal (\"<code>C</code>\") in <code>\"C\"</code>');",
        "assert('CC'.match(reCriminals) && 'CC'.match(reCriminals)[0] == 'CC', 'message: Your regex should match <em>two</em> criminals (\"<code>CC</code>\") in <code>\"CC\"</code>');",
        "assert('P1P5P4CCCP2P6P3'.match(reCriminals) && 'P1P5P4CCCP2P6P3'.match(reCriminals)[0] == 'CCC', 'message: Your regex should match <em>three</em> criminals (\"<code>CCC</code>\") in <code>\"P1P5P4CCCP2P6P3\"</code>');",
        "assert('P6P2P7P4P5CCCCCP3P1'.match(reCriminals) && 'P6P2P7P4P5CCCCCP3P1'.match(reCriminals)[0] == 'CCCCC', 'message: Your regex should match <em>five</em> criminals (\"<code>CCCCC</code>\") in <code>\"P6P2P7P4P5CCCCCP3P1\"</code>');",
        "assert(!reCriminals.test(''), 'message: Your regex should not match any criminals in <code>\"\"</code>');",
        "assert(!reCriminals.test('P1P2P3'), 'message: Your regex should not match any criminals in <code>\"P1P2P3\"</code>');",
        "assert('P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals) && 'P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals)[0] == \"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\", 'message: Your regex should match <em>fifty</em> criminals (\"<code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>\") in <code>\"P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3\"</code>.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db7367417b2b2512b9d",
      "title": "Match Beginning String Patterns",
      "description": [
        "Prior challenges showed that regular expressions can be used to look for a number of matches. They are also used to search for patterns in specific positions in strings.",
        "In an earlier challenge, you used the <code>caret</code> character (<code>^</code>) inside a <code>character set</code> to create a <code>negated character set</code> in the form <code>[^thingsThatWillNotBeMatched]</code>. Outside of a <code>character set</code>, the <code>caret</code> is used to search for patterns at the beginning of strings.",
        "<blockquote>let firstString = \"Ricky is first and can be found.\";<br>let firstRegex = /^Ricky/;<br>firstRegex.test(firstString);<br>// Returns true<br>let notFirst = \"You can't find Ricky now.\";<br>firstRegex.test(notFirst);<br>// Returns false</blockquote>",
        "<hr>",
        "Use the <code>caret</code> character in a regex to find <code>\"Cal\"</code> only in the beginning of the string <code>rickyAndCal</code>."
      ],
      "challengeSeed": [
        "let rickyAndCal = \"Cal and Ricky both like racing.\";",
        "let calRegex = /change/; // Change this line",
        "let result = calRegex.test(rickyAndCal);"
      ],
      "tests": [
        "assert(calRegex.source == \"^Cal\", 'message: Your regex should search for <code>\"Cal\"</code> with a capital letter.');",
        "assert(calRegex.flags == \"\", 'message: Your regex should not use any flags.');",
        "assert(calRegex.test(\"Cal and Ricky both like racing.\"), 'message: Your regex should match <code>\"Cal\"</code> at the beginning of the string.');",
        "assert(!calRegex.test(\"Ricky and Cal both like racing.\"), 'message: Your regex should not match <code>\"Cal\"</code> in the middle of a string.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db7367417b2b2512b9e",
      "title": "Match Ending String Patterns",
      "description": [
        "In the last challenge, you learned to use the <code>caret</code> character to search for patterns at the beginning of strings. There is also a way to search for patterns at the end of strings.",
        "You can search the end of strings using the <code>dollar sign</code> character <code>$</code> at the end of the regex.",
        "<blockquote>let theEnding = \"This is a never ending story\";<br>let storyRegex = /story$/;<br>storyRegex.test(theEnding);<br>// Returns true<br>let noEnding = \"Sometimes a story will have to end\";<br>storyRegex.test(noEnding);<br>// Returns false<br></blockquote>",
        "<hr>",
        "Use the anchor character (<code>$</code>) to match the string <code>\"caboose\"</code> at the end of the string <code>caboose</code>."
      ],
      "challengeSeed": [
        "let caboose = \"The last car on a train is the caboose\";",
        "let lastRegex = /change/; // Change this line",
        "let result = lastRegex.test(caboose);"
      ],
      "tests": [
        "assert(lastRegex.source == \"caboose$\", 'message: You should search for <code>\"caboose\"</code> with the dollar sign <code>$</code> anchor in your regex.');",
        "assert(lastRegex.flags == \"\", 'message: Your regex should not use any flags.');",
        "assert(lastRegex.test(\"The last car on a train is the caboose\"), 'message: You should match <code>\"caboose\"</code> at the end of the string <code>\"The last car on a train is the caboose\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db7367417b2b2512b9f",
      "title": "Match All Letters and Numbers",
      "description": [
        "Using character classes, you were able to search for all letters of the alphabet with <code>[a-z]</code>. This kind of character class is common enough that there is a shortcut for it, although it includes a few extra characters as well.",
        "The closest character class in JavaScript to match the alphabet is <code>\\w</code>. This shortcut is equal to <code>[A-Za-z0-9_]</code>. This character class matches upper and lowercase letters plus numbers. Note, this character class also includes the underscore character (<code>_</code>).",
        "<blockquote>let longHand = /[A-Za-z0-9_]+/;<br>let shortHand = /\\w+/;<br>let numbers = \"42\";<br>let varNames = \"important_var\";<br>longHand.test(numbers); // Returns true<br>shortHand.test(numbers); // Returns true<br>longHand.test(varNames); // Returns true<br>shortHand.test(varNames); // Returns true</blockquote>",
        "These shortcut character classes are also known as <code>shorthand character classes</code>.",
        "<hr>",
        "Use the shorthand character class <code>\\w</code> to count the number of alphanumeric characters in various quotes and strings."
      ],
      "challengeSeed": [
        "let quoteSample = \"The five boxing wizards jump quickly.\";",
        "let alphabetRegexV2 = /change/; // Change this line",
        "let result = quoteSample.match(alphabetRegexV2).length;"
      ],
      "tests": [
        "assert(alphabetRegexV2.global, 'message: Your regex should use the global flag.');",
        "assert(\"The five boxing wizards jump quickly.\".match(alphabetRegexV2).length === 31, 'message: Your regex should find 31 alphanumeric characters in <code>\"The five boxing wizards jump quickly.\"</code>');",
        "assert(\"Pack my box with five dozen liquor jugs.\".match(alphabetRegexV2).length === 32, 'message: Your regex should find 32 alphanumeric characters in <code>\"Pack my box with five dozen liquor jugs.\"</code>');",
        "assert(\"How vexingly quick daft zebras jump!\".match(alphabetRegexV2).length === 30, 'message: Your regex should find 30 alphanumeric characters in <code>\"How vexingly quick daft zebras jump!\"</code>');",
        "assert(\"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.\".match(alphabetRegexV2).length === 36, 'message: Your regex should find 36 alphanumeric characters in <code>\"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db8367417b2b2512ba0",
      "title": "Match Everything But Letters and Numbers",
      "description": [
        "You've learned that you can use a shortcut to match alphanumerics <code>[A-Za-z0-9_]</code> using <code>\\w</code>. A natural pattern you might want to search for is the opposite of alphanumerics.",
        "You can search for the opposite of the <code>\\w</code> with <code>\\W</code>. Note, the opposite pattern uses a capital letter. This shortcut is the same as <code>[^A-Za-z0-9_]</code>.",
        "<blockquote>let shortHand = /\\W/;<br>let numbers = \"42%\";<br>let sentence = \"Coding!\";<br>numbers.match(shortHand); // Returns [\"%\"]<br>sentence.match(shortHand); // Returns [\"!\"]<br></blockquote>",
        "<hr>",
        "Use the shorthand character class <code>\\W</code> to count the number of non-alphanumeric characters in various quotes and strings."
      ],
      "challengeSeed": [
        "let quoteSample = \"The five boxing wizards jump quickly.\";",
        "let nonAlphabetRegex = /change/; // Change this line",
        "let result = quoteSample.match(nonAlphabetRegex).length;"
      ],
      "tests": [
        "assert(nonAlphabetRegex.global, 'message: Your regex should use the global flag.');",
        "assert(\"The five boxing wizards jump quickly.\".match(nonAlphabetRegex).length == 6, 'message: Your regex should find 6 non-alphanumeric characters in <code>\"The five boxing wizards jump quickly.\"</code>.');",
        "assert(\"Pack my box with five dozen liquor jugs.\".match(nonAlphabetRegex).length == 8, 'message: Your regex should find 8 non-alphanumeric characters in <code>\"Pack my box with five dozen liquor jugs.\"</code>');",
        "assert(\"How vexingly quick daft zebras jump!\".match(nonAlphabetRegex).length == 6, 'message: Your regex should find 6 non-alphanumeric characters in <code>\"How vexingly quick daft zebras jump!\"</code>');",
        "assert(\"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.\".match(nonAlphabetRegex).length == 12, 'message: Your regex should find 12 non-alphanumeric characters in <code>\"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "5d712346c441eddfaeb5bdef",
      "title": "Match All Numbers",
      "description": [
        "You've learned shortcuts for common string patterns like alphanumerics. Another common pattern is looking for just digits or numbers.",
        "The shortcut to look for digit characters is <code>\\d</code>, with a lowercase <code>d</code>. This is equal to the character class <code>[0-9]</code>, which looks for a single character of any number between zero and nine.",
        "<hr>",
        "Use the shorthand character class <code>\\d</code> to count how many digits are in movie titles. Written out numbers (\"six\" instead of 6) do not count."
      ],
      "challengeSeed": [
        "let numString = \"Your sandwich will be $5.00\";",
        "let numRegex = /change/; // Change this line",
        "let result = numString.match(numRegex).length;"
      ],
      "tests": [
        "assert(/\\\\d/.test(numRegex.source), 'message: Your regex should use the shortcut character to match digit characters');",
        "assert(numRegex.global, 'message: Your regex should use the global flag.');",
        "assert(\"9\".match(numRegex).length == 1, 'message: Your regex should find 1 digit in <code>\"9\"</code>.');",
        "assert(\"Catch 22\".match(numRegex).length == 2, 'message: Your regex should find 2 digits in <code>\"Catch 22\"</code>.');",
        "assert(\"101 Dalmatians\".match(numRegex).length == 3, 'message: Your regex should find 3 digits in <code>\"101 Dalmatians\"</code>.');",
        "assert(\"One, Two, Three\".match(numRegex) == null, 'message: Your regex should find no digits in <code>\"One, Two, Three\"</code>.');",
        "assert(\"21 Jump Street\".match(numRegex).length == 2, 'message: Your regex should find 2 digits in <code>\"21 Jump Street\"</code>.');",
        "assert(\"2001: A Space Odyssey\".match(numRegex).length == 4, 'message: Your regex should find 4 digits in <code>\"2001: A Space Odyssey\"</code>.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db8367417b2b2512ba1",
      "title": "Match All Non-Numbers",
      "description": [
        "The last challenge showed how to search for digits using the shortcut <code>\\d</code> with a lowercase <code>d</code>. You can also search for non-digits using a similar shortcut that uses an uppercase <code>D</code> instead.",
        "The shortcut to look for non-digit characters is <code>\\D</code>. This is equal to the character class <code>[^0-9]</code>, which looks for a single character that is not a number between zero and nine.",
        "<hr>",
        "Use the shorthand character class for non-digits <code>\\D</code> to count how many non-digits are in movie titles."
      ],
      "challengeSeed": [
        "let numString = \"Your sandwich will be $5.00\";",
        "let noNumRegex = /change/; // Change this line",
        "let result = numString.match(noNumRegex).length;"
      ],
      "tests": [
        "assert(/\\\\D/.test(noNumRegex.source), 'message: Your regex should use the shortcut character to match non-digit characters');",
        "assert(noNumRegex.global, 'message: Your regex should use the global flag.');",
        "assert(\"9\".match(noNumRegex) == null, 'message: Your regex should find no non-digits in <code>\"9\"</code>.');",
        "assert(\"Catch 22\".match(noNumRegex).length == 6, 'message: Your regex should find 6 non-digits in <code>\"Catch 22\"</code>.');",
        "assert(\"101 Dalmatians\".match(noNumRegex).length == 11, 'message: Your regex should find 11 non-digits in <code>\"101 Dalmatians\"</code>.');",
        "assert(\"One, Two, Three\".match(noNumRegex).length == 15, 'message: Your regex should find 15 non-digits in <code>\"One, Two, Three\"</code>.');",
        "assert(\"21 Jump Street\".match(noNumRegex).length == 12, 'message: Your regex should find 12 non-digits in <code>\"21 Jump Street\"</code>.');",
        "assert(\"2001: A Space Odyssey\".match(noNumRegex).length == 17, 'message: Your regex should find 17 non-digits in <code>\"2001: A Space Odyssey\"</code>.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db8367417b2b2512ba2",
      "title": "Restrict Possible Usernames",
      "description": [
        "Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites.",
        "You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username.",
        "1) The only numbers in the username have to be at the end. There can be zero or more of them at the end.",
        "2) Username letters can be lowercase and uppercase.",
        "3) Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.",
        "<hr>",
        "Change the regex <code>userCheck</code> to fit the constraints listed above."
      ],
      "challengeSeed": [
        "let username = \"JackOfAllTrades\";",
        "let userCheck = /change/; // Change this line",
        "let result = userCheck.test(username);"
      ],
      "tests": [
        "assert(userCheck.test(\"JACK\"), 'message: Your regex should match <code>JACK</code>');",
        "assert(!userCheck.test(\"J\"), 'message: Your regex should not match <code>J</code>');",
        "assert(userCheck.test(\"Oceans11\"), 'message: Your regex should match <code>Oceans11</code>');",
        "assert(userCheck.test(\"RegexGuru\"), 'message: Your regex should match <code>RegexGuru</code>');",
        "assert(!userCheck.test(\"007\"), 'message: Your regex should not match <code>007</code>');",
        "assert(!userCheck.test(\"9\"), 'message: Your regex should not match <code>9</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db8367417b2b2512ba3",
      "title": "Match Whitespace",
      "description": [
        "The challenges so far have covered matching letters of the alphabet and numbers. You can also match the whitespace or spaces between letters.",
        "You can search for whitespace using <code>\\s</code>, which is a lowercase <code>s</code>. This pattern not only matches whitespace, but also carriage return, tab, form feed, and new line characters. You can think of it as similar to the character class <code>[ \\r\\t\\f\\n\\v]</code>.",
        "<blockquote>let whiteSpace = \"Whitespace. Whitespace everywhere!\"<br>let spaceRegex = /\\s/g;<br>whiteSpace.match(spaceRegex);<br>// Returns [\" \", \" \"]<br></blockquote>",
        "<hr>",
        "Change the regex <code>countWhiteSpace</code> to look for multiple whitespace characters in a string."
      ],
      "challengeSeed": [
        "let sample = \"Whitespace is important in separating words\";",
        "let countWhiteSpace = /change/; // Change this line",
        "let result = sample.match(countWhiteSpace);"
      ],
      "tests": [
        "assert(countWhiteSpace.global, 'message: Your regex should use the global flag.');",
        "assert(\"Men are from Mars and women are from Venus.\".match(countWhiteSpace).length == 8, 'message: Your regex should find eight spaces in <code>\"Men are from Mars and women are from Venus.\"</code>');",
        "assert(\"Space: the final frontier.\".match(countWhiteSpace).length == 3, 'message: Your regex should find three spaces in <code>\"Space: the final frontier.\"</code>');",
        "assert(\"MindYourPersonalSpace\".match(countWhiteSpace) == null, 'message: Your regex should find no spaces in <code>\"MindYourPersonalSpace\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db9367417b2b2512ba4",
      "title": "Match Non-Whitespace Characters",
      "description": [
        "You learned about searching for whitespace using <code>\\s</code>, with a lowercase <code>s</code>. You can also search for everything except whitespace.",
        "Search for non-whitespace using <code>\\S</code>, which is an uppercase <code>s</code>. This pattern will not match whitespace, carriage return, tab, form feed, and new line characters. You can think of it being similar to the character class <code>[^ \\r\\t\\f\\n\\v]</code>.",
        "<blockquote>let whiteSpace = \"Whitespace. Whitespace everywhere!\"<br>let nonSpaceRegex = /\\S/g;<br>whiteSpace.match(nonSpaceRegex).length; // Returns 32</blockquote>",
        "<hr>",
        "Change the regex <code>countNonWhiteSpace</code> to look for multiple non-whitespace characters in a string."
      ],
      "challengeSeed": [
        "let sample = \"Whitespace is important in separating words\";",
        "let countNonWhiteSpace = /change/; // Change this line",
        "let result = sample.match(countNonWhiteSpace);"
      ],
      "tests": [
        "assert(countNonWhiteSpace.global, 'message: Your regex should use the global flag.');",
        "assert(\"Men are from Mars and women are from Venus.\".match(countNonWhiteSpace).length == 35, 'message: Your regex should find 35 non-spaces in <code>\"Men are from Mars and women are from Venus.\"</code>');",
        "assert(\"Space: the final frontier.\".match(countNonWhiteSpace).length == 23, 'message: Your regex should find 23 non-spaces in <code>\"Space: the final frontier.\"</code>');",
        "assert(\"MindYourPersonalSpace\".match(countNonWhiteSpace).length == 21, 'message: Your regex should find 21 non-spaces in <code>\"MindYourPersonalSpace\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db9367417b2b2512ba5",
      "title": "Specify Upper and Lower Number of Matches",
      "description": [
        "Recall that you use the plus sign <code>+</code> to look for one or more characters and the asterisk <code>*</code> to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.",
        "You can specify the lower and upper number of patterns with <code>quantity specifiers</code>. Quantity specifiers are used with curly brackets (<code>{</code> and <code>}</code>). You put two numbers between the curly brackets - for the lower and upper number of patterns.",
        "For example, to match only the letter <code>a</code> appearing between <code>3</code> and <code>5</code> times in the string <code>\"ah\"</code>, your regex would be <code>/a{3,5}h/</code>.",
        "<blockquote>let A4 = \"aaaah\";<br>let A2 = \"aah\";<br>let multipleA = /a{3,5}h/;<br>multipleA.test(A4); // Returns true<br>multipleA.test(A2); // Returns false</blockquote>",
        "<hr>",
        "Change the regex <code>ohRegex</code> to match only <code>3</code> to <code>6</code> letter <code>h</code>'s in the word <code>\"Oh no\"</code>."
      ],
      "challengeSeed": [
        "let ohStr = \"Ohhh no\";",
        "let ohRegex = /change/; // Change this line",
        "let result = ohRegex.test(ohStr);"
      ],
      "tests": [
        "assert(ohRegex.source.match(/{.*?}/).length > 0, 'message: Your regex should use curly brackets.');",
        "assert(!ohRegex.test(\"Ohh no\"), 'message: Your regex should not match <code>\"Ohh no\"</code>');",
        "assert(ohRegex.test(\"Ohhh no\"), 'message: Your regex should match <code>\"Ohhh no\"</code>');",
        "assert(ohRegex.test(\"Ohhhh no\"), 'message: Your regex should match <code>\"Ohhhh no\"</code>');",
        "assert(ohRegex.test(\"Ohhhhh no\"), 'message: Your regex should match <code>\"Ohhhhh no\"</code>');",
        "assert(ohRegex.test(\"Ohhhhhh no\"), 'message: Your regex should match <code>\"Ohhhhhh no\"</code>');",
        "assert(!ohRegex.test(\"Ohhhhhhh no\"), 'message: Your regex should not match <code>\"Ohhhhhhh no\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db9367417b2b2512ba6",
      "title": "Specify Only the Lower Number of Matches",
      "description": [
        "You can specify the lower and upper number of patterns with <code>quantity specifiers</code> using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit.",
        "To only specify the lower number of patterns, keep the first number followed by a comma.",
        "For example, to match only the string <code>\"hah\"</code> with the letter <code>a</code> appearing at least <code>3</code> times, your regex would be <code>/ha{3,}h/</code>.",
        "<blockquote>let A4 = \"haaaah\";<br>let A2 = \"haah\";<br>let A100 = \"h\" + \"a\".repeat(100) + \"h\";<br>let multipleA = /ha{3,}h/;<br>multipleA.test(A4); // Returns true<br>multipleA.test(A2); // Returns false<br>multipleA.test(A100); // Returns true</blockquote>",
        "<hr>",
        "Change the regex <code>haRegex</code> to match the word <code>\"Hazzah\"</code> only when it has four or more letter <code>z</code>'s."
      ],
      "challengeSeed": [
        "let haStr = \"Hazzzzah\";",
        "let haRegex = /change/; // Change this line",
        "let result = haRegex.test(haStr);"
      ],
      "tests": [
        "assert(haRegex.source.match(/{.*?}/).length > 0, 'message: Your regex should use curly brackets.');",
        "assert(!haRegex.test(\"Hazzah\"), 'message: Your regex should not match <code>\"Hazzah\"</code>');",
        "assert(!haRegex.test(\"Hazzzah\"), 'message: Your regex should not match <code>\"Hazzzah\"</code>');",
        "assert(haRegex.test(\"Hazzzzah\"), 'message: Your regex should match <code>\"Hazzzzah\"</code>');",
        "assert(haRegex.test(\"Hazzzzzah\"), 'message: Your regex should match <code>\"Hazzzzzah\"</code>');",
        "assert(haRegex.test(\"Hazzzzzzah\"), 'message: Your regex should match <code>\"Hazzzzzzah\"</code>');",
        "assert(haRegex.test(\"Ha\" + \"z\".repeat(30) + \"ah\"), 'message: Your regex should match <code>\"Hazzah\"</code> with 30 <code>z</code>\\'s in it.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7db9367417b2b2512ba7",
      "title": "Specify Exact Number of Matches",
      "description": [
        "You can specify the lower and upper number of patterns with <code>quantity specifiers</code> using curly brackets. Sometimes you only want a specific number of matches.",
        "To specify a certain number of patterns, just have that one number between the curly brackets.",
        "For example, to match only the word <code>\"hah\"</code> with the letter <code>a</code> <code>3</code> times, your regex would be <code>/ha{3}h/</code>.",
        "<blockquote>let A4 = \"haaaah\";<br>let A3 = \"haaah\";<br>let A100 = \"h\" + \"a\".repeat(100) + \"h\";<br>let multipleHA = /a{3}h/;<br>multipleHA.test(A4); // Returns false<br>multipleHA.test(A3); // Returns true<br>multipleHA.test(A100); // Returns false</blockquote>",
        "<hr>",
        "Change the regex <code>timRegex</code> to match the word <code>\"Timber\"</code> only when it has four letter <code>m</code>'s."
      ],
      "challengeSeed": [
        "let timStr = \"Timmmmber\";",
        "let timRegex = /change/; // Change this line",
        "let result = timRegex.test(timStr);"
      ],
      "tests": [
        "assert(timRegex.source.match(/{.*?}/).length > 0, 'message: Your regex should use curly brackets.');",
        "assert(!timRegex.test(\"Timber\"), 'message: Your regex should not match <code>\"Timber\"</code>');",
        "assert(!timRegex.test(\"Timmber\"), 'message: Your regex should not match <code>\"Timmber\"</code>');",
        "assert(!timRegex.test(\"Timmmber\"), 'message: Your regex should not match <code>\"Timmmber\"</code>');",
        "assert(timRegex.test(\"Timmmmber\"), 'message: Your regex should match <code>\"Timmmmber\"</code>');",
        "assert(!timRegex.test(\"Ti\" + \"m\".repeat(30) + \"ber\"), 'message: Your regex should not match <code>\"Timber\"</code> with 30 <code>m</code>\\'s in it.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7dba367417b2b2512ba8",
      "title": "Check for All or None",
      "description": [
        "Sometimes the patterns you want to search for may have parts of it that may or may not exist. However, it may be important to check for them nonetheless.",
        "You can specify the possible existence of an element with a question mark, <code>?</code>. This checks for zero or one of the preceding element. You can think of this symbol as saying the previous element is optional.",
        "For example, there are slight differences in American and British English and you can use the question mark to match both spellings.",
        "<blockquote>let american = \"color\";<br>let british = \"colour\";<br>let rainbowRegex= /colou?r/;<br>rainbowRegex.test(american); // Returns true<br>rainbowRegex.test(british); // Returns true</blockquote>",
        "<hr>",
        "Change the regex <code>favRegex</code> to match both the American English (favorite) and the British English (favourite) version of the word."
      ],
      "challengeSeed": [
        "let favWord = \"favorite\";",
        "let favRegex = /change/; // Change this line",
        "let result = favRegex.test(favWord);"
      ],
      "tests": [
        "assert(favRegex.source.match(/\\?/).length > 0, 'message: Your regex should use the optional symbol, <code>?</code>.');",
        "assert(favRegex.test(\"favorite\"), 'message: Your regex should match <code>\"favorite\"</code>');",
        "assert(favRegex.test(\"favourite\"), 'message: Your regex should match <code>\"favourite\"</code>');",
        "assert(!favRegex.test(\"fav\"), 'message: Your regex should not match <code>\"fav\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7dba367417b2b2512ba9",
      "title": "Positive and Negative Lookahead",
      "description": [
        "<code>Lookaheads</code> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string.",
        "There are two kinds of <code>lookaheads</code>: <code>positive lookahead</code> and <code>negative lookahead</code>.",
        "A <code>positive lookahead</code> will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as <code>(?=...)</code> where the <code>...</code> is the required part that is not matched.",
        "On the other hand, a <code>negative lookahead</code> will look to make sure the element in the search pattern is not there. A negative lookahead is used as <code>(?!...)</code> where the <code>...</code> is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present.",
        "Lookaheads are a bit confusing but some examples will help.",
        "<blockquote>let quit = \"qu\";<br>let noquit = \"qt\";<br>let quRegex= /q(?=u)/;<br>let qRegex = /q(?!u)/;<br>quit.match(quRegex); // Returns [\"q\"]<br>noquit.match(qRegex); // Returns [\"q\"]</blockquote>",
        "A more practical use of <code>lookaheads</code> is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number:",
        "<blockquote>let password = \"abc123\";<br>let checkPass = /(?=\\w{3,6})(?=\\D*\\d)/;<br>checkPass.test(password); // Returns true</blockquote>",
        "<hr>",
        "Use <code>lookaheads</code> in the <code>pwRegex</code> to match passwords that are greater than 5 characters long and have two consecutive digits."
      ],
      "challengeSeed": [
        "let sampleWord = \"astronaut\";",
        "let pwRegex = /change/; // Change this line",
        "let result = pwRegex.test(sampleWord);"
      ],
      "tests": [
        "assert(pwRegex.source.match(/\\(\\?=.*?\\)\\(\\?=.*?\\)/) !== null, 'message: Your regex should use two positive <code>lookaheads</code>.');",
        "assert(!pwRegex.test(\"astronaut\"), 'message: Your regex should not match <code>\"astronaut\"</code>');",
        "assert(!pwRegex.test(\"airplanes\"), 'message: Your regex should not match <code>\"airplanes\"</code>');",
        "assert(pwRegex.test(\"bana12\"), 'message: Your regex should match <code>\"bana12\"</code>');",
        "assert(pwRegex.test(\"abc123\"), 'message: Your regex should match <code>\"abc123\"</code>');",
        "assert(!pwRegex.test(\"123\"), 'message: Your regex should not match <code>\"123\"</code>');",
        "assert(!pwRegex.test(\"1234\"), 'message: Your regex should not match <code>\"1234\"</code>');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7dbb367417b2b2512baa",
      "title": "Reuse Patterns Using Capture Groups",
      "description": [
        "Some patterns you search for will occur multiple times in a string. It is wasteful to manually repeat that regex. There is a better way to specify when you have multiple repeat substrings in your string.",
        "You can search for repeat substrings using <code>capture groups</code>. Parentheses, <code>(</code> and <code>)</code>, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses.",
        "To specify where that repeat string will appear, you use a backslash (<code>\\</code>) and then a number. This number starts at 1 and increases with each additional capture group you use. An example would be <code>\\1</code> to match the first group.",
        "The example below matches any word that occurs twice separated by a space:",
        "<blockquote>let repeatStr = \"regex regex\";<br>let repeatRegex = /(\\w+)\\s\\1/;<br>repeatRegex.test(repeatStr); // Returns true<br>repeatStr.match(repeatRegex); // Returns [\"regex regex\", \"regex\"]</blockquote>",
        "Using the <code>.match()</code> method on a string will return an array with the string it matches, along with its capture group.",
        "<hr>",
        "Use <code>capture groups</code> in <code>reRegex</code> to match numbers that are repeated only three times in a string, each separated by a space."
      ],
      "challengeSeed": [
        "let repeatNum = \"42 42 42\";",
        "let reRegex = /change/; // Change this line",
        "let result = reRegex.test(repeatNum);"
      ],
      "tests": [
        "assert(reRegex.source.match(/\\\\d/), 'message: Your regex should use the shorthand character class for digits.');",
        "assert(reRegex.source.match(/\\\\\\d/g).length === 2, 'message: Your regex should reuse the capture group twice.');",
        "assert(reRegex.source.match(/\\\\s/g).length === 2, 'message: Your regex should have two spaces separating the three numbers.');",
        "assert(reRegex.test(\"42 42 42\"), 'message: Your regex should match <code>\"42 42 42\"</code>.');",
        "assert(reRegex.test(\"100 100 100\"), 'message: Your regex should match <code>\"100 100 100\"</code>.');",
        "assert.equal((\"42 42 42 42\").match(reRegex.source), null, 'message: Your regex should not match <code>\"42 42 42 42\"</code>.');",
        "assert.equal((\"42 42\").match(reRegex.source), null, 'message: Your regex should not match <code>\"42 42\"</code>.');",
        "assert(!reRegex.test(\"101 102 103\"), 'message: Your regex should not match <code>\"101 102 103\"</code>.');",
        "assert(!reRegex.test(\"1 2 3\"), 'message: Your regex should not match <code>\"1 2 3\"</code>.');",
        "assert(reRegex.test(\"10 10 10\"), 'message: Your regex should match <code>\"10 10 10\"</code>.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7dbb367417b2b2512bab",
      "title": "Use Capture Groups to Search and Replace",
      "description": [
        "Searching is useful. However, you can make searching even more powerful when it also changes (or replaces) the text you match.",
        "You can search and replace text in a string using <code>.replace()</code> on a string. The inputs for <code>.replace()</code> is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.",
        "<blockquote>let wrongText = \"The sky is silver.\";<br>let silverRegex = /silver/;<br>wrongText.replace(silverRegex, \"blue\");<br>// Returns \"The sky is blue.\"</blockquote>",
        "You can also access capture groups in the replacement string with dollar signs (<code>$</code>).",
        "<blockquote>\"Code Camp\".replace(/(\\w+)\\s(\\w+)/, '$2 $1');<br>// Returns \"Camp Code\"</blockquote>",
        "<hr>",
        "Write a regex so that it will search for the string <code>\"good\"</code>. Then update the <code>replaceText</code> variable to replace <code>\"good\"</code> with <code>\"okey-dokey\"</code>."
      ],
      "challengeSeed": [
        "let huhText = \"This sandwich is good.\";",
        "let fixRegex = /change/; // Change this line",
        "let replaceText = \"\"; // Change this line",
        "let result = huhText.replace(fixRegex, replaceText);"
      ],
      "tests": [
        "assert(code.match(/\\.replace\\(.*\\)/), 'message: You should use <code>.replace()</code> to search and replace.');",
        "assert(result == \"This sandwich is okey-dokey.\" && replaceText === \"okey-dokey\", 'message: Your regex should change <code>\"This sandwich is good.\"</code> to <code>\"This sandwich is okey-dokey.\"</code>');",
        "assert(code.match(/result\\s*=\\s*huhText\\.replace\\(.*?\\)/), 'message: You should not change the last line.');"
      ],
      "solutions": [],
      "hints": [],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    },
    {
      "id": "587d7dbb367417b2b2512bac",
      "title": "Remove Whitespace from Start and End",
      "description": [
        "Sometimes whitespace characters around strings are not wanted but are there. Typical processing of strings is to remove the whitespace at the start and end of it.",
        "<hr>",
        "Write a regex and use the appropriate string methods to remove whitespace at the beginning and end of strings.",
        "<strong>Note</strong><br>The <code>.trim()</code> method would work here, but you'll need to complete this challenge using regular expressions."
      ],
      "challengeSeed": [
        "let hello = \"   Hello, World!  \";",
        "let wsRegex = /change/; // Change this line",
        "let result = hello; // Change this line"
      ],
      "tests": [
        "assert(result == \"Hello, World!\", 'message: <code>result</code> should equal to <code>\"Hello, World!\"</code>');",
        "assert(!code.match(/\\.trim\\(.*?\\)/), 'message: You should not use the <code>.trim()</code> method.');",
        "assert(!code.match(/result\\s*=\\s*\".*?\"/), 'message: The <code>result</code> variable should not be set equal to a string.');"
      ],
      "solutions": [],
      "hints": [
        "You can use .replace() to remove the matched items by replacing them with an empty string."
      ],
      "type": "waypoint",
      "releasedOn": "Feb 17, 2017",
      "challengeType": 1,
      "translations": {}
    }
  ]
}
