JAVASCRIPT IN PRACTICE

Write a regular expression

Match the required strings and reject the others. Practice regular expressions with concrete examples.

  • Character classes
  • Anchors
  • Matches and exclusions
Preview the first challenge →

Solving requires a free account.

Selected challenges to get started

Pick a challenge and explore the rules through a concrete example.

Warm-up

YYYY-MM-DD format

Match a date in YYYY-MM-DD format. Check the shape only: 4 ASCII digits, hyphen, 2 digits, hyphen, 2 digits. Do not validate the calendar; 2024-99-99 matches.

Preview challenge → Free account required to solve
Warm-up

Numbers only

Match an entire non-empty string containing only ASCII digits 0–9. No sign, whitespace or decimal separator.

Preview challenge → Free account required to solve
Easy

Simplified email address

Match the entire simplified address: a non-empty local part using ASCII letters, digits and ._%+-, then a domain with alphanumeric labels (hyphens only inside), at least…

Preview challenge → Free account required to solve

Ready for more?

Available challenges: 7.

See all challenges →

The full catalogue requires a free account.

How should you approach these challenges?

Regular expression exercises teach you to recognise text formats and reject non-matching data. They are useful for filtering logs, searching text and checking the shape of form values. Matching a format does not always prove validity, such as whether a calendar date exists.

Compare strings that should match with those that must be rejected. Build a clear pattern expressing the difference first. Check start and end anchors, repetition counts and escaped characters. After each change, run every example, not just the last failing case.

Explore an example: YYYY-MM-DD format →

Read the description without logging in. Solving requires a free account.