5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Regex Validation lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Check the value is nothing but digits.
Check a value with a letter is refused.
Accept three capitals followed by three digits.
Accept the number with or without a leading plus.
Check the shape with a pattern and the range with a number.
Without anchors a mixed value passes.
The code requires capitals, so lowercase must be refused.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceA pattern cannot express a numeric range, so check the number.
A literal plus must be escaped.
A star allows an empty string, which should be refused.