Want to get confident with number regex?
Start with exercises 01, 02, 06, 16, and 17. They cover digits only, exact length, signed integers, and decimals.
Guide: Regex for NumbersPractice regex through short problems, real examples, and explained solutions. Start with numbers and simple patterns, then move into groups, JavaScript, lookarounds, and extraction.
Start with exercises 01, 02, 06, 16, and 17. They cover digits only, exact length, signed integers, and decimals.
Guide: Regex for NumbersExercises 19, 20, 24, 28, and 29 cover capture, identifiers, named groups, and extraction — patterns that map naturally to JavaScript RegExp work.
Guide: JavaScript RegexMatch 12345; reject A123, 12-34, and an empty string.
^\d+$
Anchors require the entire string to contain one or more digits.
Match 2026; reject 26 and 20260.
^\d{4}$The {4} quantifier requires exactly four digits.
Match RegexArena; reject Regex123 and regex-arena.
^[A-Za-z]+$
This class covers ASCII letters; use Unicode-aware patterns when other alphabets matter.
Match DEV-2026 and DEV2026; reject DE-2026.
^DEV-?\d{4}$The ? makes the hyphen optional and \d{4} requires four digits.
Match regex-arena and regex2026; reject spaces and duplicate hyphens.
^[a-z0-9]+(?:-[a-z0-9]+)*$
Each additional block must be separated by a single hyphen.
Match 12345 and 12345678; reject shorter or longer values.
^\d{5,8}$The {5,8} quantifier sets minimum and maximum length.
Match ERROR connection lost; reject INFO ERROR.
^ERROR\b
The start anchor fixes the position and closes the word.
Find one or more spaces, tabs, or line breaks so they can be replaced.
\s+
\s represents whitespace and + captures a sequence.
Match cat, cats, dog, and dogs.
^(cat|dog)s?$
Alternation selects cat/dog and s? makes the plural optional.
Match #22aa77 and #FFFFFF; reject 22aa77.
^#[0-9A-Fa-f]{6}$The hash is literal and the class requires six hexadecimal digits.
Match 94105 and 94105-1234; reject 9410.
^\d{5}(?:-\d{4})?$Five digits are required and the ZIP+4 suffix is optional.
Match 11/10/2026; reject 2026-10-11.
^\d{2}/\d{2}/\d{4}$This checks visual format, not whether the calendar date exists.
Match (415) 555-1234; reject 415 555-1234.
^\(\d{3}\) \d{3}-\d{4}$Literal parentheses must be escaped.
Match dev@example.com; reject dev@site and @example.com.
^[\w.-]+@[\w.-]+\.[A-Za-z]{2,}$Useful for practice, but not a complete implementation of email standards.
Match https://regexarena.com/en/; reject ftp://example.com.
^https?://[\w.-]+\.[A-Za-z]{2,}(?:/.*)?$The optional s covers HTTP/HTTPS and the last group makes the path optional.
Match 42, -42, and +42; reject 4.2.
^[+-]?\d+$
The sign is optional and the rest must contain digits only.
Match 42, 42.50, and -42,50.
^[+-]?\d+(?:[.,]\d+)?$
The decimal portion is optional and accepts a dot or comma.
Match lines beginning with INFO, WARN, or ERROR followed by YYYY-MM-DD.
^(INFO|WARN|ERROR)\s+\d{4}-\d{2}-\d{2}Alternation captures the log level and the second part requires the date.
In dev@example.com, capture dev as group 1 and example.com as group 2.
^([\w.-]+)@([\w.-]+\.[A-Za-z]{2,})$Parentheses create capture groups that can be reused or inspected.
Match userName, _cache, and $value; reject 2users.
^[A-Za-z_$][\w$]*$
The first character has stricter rules; later characters may include word characters and $.
Capture DEV123 only when it is immediately followed by -OK.
^DEV\d{3}(?=-OK$)The lookahead checks context without consuming -OK.
Match lowercase names except the exact word admin.
^(?!admin$)[a-z]+$
The negative lookahead excludes the reserved value before testing the rest.
In $ 150, capture only 150.
(?<=\$ )\d+$
The lookbehind requires the prefix without including it in the match.
Capture DEV-2026 in a named group called code.
(?<code>[A-Z]{3}-\d{4})Named groups make extracted data easier to understand in JavaScript and the visualizer.
Find the the or regex regex; reject regex arena.
\b(\w+)\s+\1\b
requires the second word to equal what group 1 captured.
Require at least 8 characters, one uppercase letter, and one digit, using letters and digits only.
^(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$Two lookaheads verify requirements before the allowed character set is validated.
Match files ending in jpg, jpeg, png, or webp using the i flag.
^.+\.(?:jpe?g|png|webp)$
The non-capturing group collects extensions and jpe?g covers jpg/jpeg.
Capture day, month, and year from 11/10/2026 using named groups.
^(?<day>\d{2})/(?<month>\d{2})/(?<year>\d{4})$Each date part becomes available by name for later extraction.
For an HTTP/HTTPS URL, capture the host as host and the optional path as path.
^https?://(?<host>[\w.-]+\.[A-Za-z]{2,})(?<path>/.*)?$Named groups split useful parts while still checking the overall format.
Capture DEV-2026 only after ID: and before ;OK.
(?<=ID:)(?<code>[A-Z]{3}-\d{4})(?=;OK$)Combine lookbehind, a named group, and lookahead in one challenge.
Turn practice into a habit: test patterns, play missions, and use smart review to reinforce weaker concepts.