Skip to main content

JavaScript Regex Characters — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Regex Characters lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(5)

  1. 1

    Match any digit

    easy10 min

    Report whether the text contains a digit.

  2. 2

    Use your own set

    easy10 min

    Report whether the word contains a vowel.

  3. 3

    Use a range

    easy10 min

    Report whether the text contains a capital letter.

  4. 4

    Exclude a set

    easy10 min

    Report whether the code contains anything that is not a digit.

  5. 5

    Escape a real dot

    medium10 min

    Match a literal dot in the file name.

Find the bug(5)

  1. 1

    Fix the unescaped dot

    easy8 min

    An unescaped dot matches any character at all.

  2. 2

    Fix the wrong class

    easy8 min

    The letter class does not match digits.

  3. 3

    Fix the caret placed outside

    easy8 min

    A caret inside the brackets is what inverts the set.

  4. 4

    Fix the range written backwards

    easy8 min

    A range must go from the lower character to the higher one.

  5. 5

    Fix the whitespace class

    easy8 min

    A literal space misses tabs and newlines.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace