/^/

Regex Challenges

20 hands-on puzzles across four difficulty levels. Progress is saved locally in your browser.

EasyValidation

Hex Color Finder

Write a regex that matches valid hexadecimal color codes, either the short form (#fff) or the long form (#ffffff). The pattern must reject codes with the wrong number of digits or non-hex characters.

EasyValidation

Valid Username Checker

Write a regex that validates usernames: they must start with a letter, be 3-16 characters total, and contain only letters, digits, or underscores.

EasyText Extraction

Digit Sequence Extractor

Write a regex that detects whether a piece of text contains a run of one or more digits, so it could be used to pull numbers like order counts or prices out of a sentence.

EasyValidation

Phone Number Format Check

Write a regex that validates US-style phone numbers written strictly as three digits, a dash, three digits, a dash, then four digits (e.g. 123-456-7890).

EasyText Processing

Alphabetic Word Matcher

Write a regex that matches strings made up of alphabetic letters only, with no digits, punctuation, or spaces allowed anywhere.

EasyText Processing

Leading/Trailing Whitespace Finder

Write a regex you could pass to .replace() to detect whitespace that sits at the very start or very end of a string (the kind you'd want to trim), while ignoring whitespace in the middle of the text.

MediumParsing

Basic Quoted String Matcher

Write a regex that matches a string fully wrapped in double quotes, where the content between the quotes contains no quote characters at all. This is a simplified version that doesn't need to handle escaped quotes.

MediumParsing

Key=Value Pair Matcher

Write a regex that matches simple configuration lines in the form key=value, where both the key and value consist of word characters only, with exactly one equals sign and no missing sides.

MediumText Processing

Extra Space Detector

Write a regex intended for use with .replace() to detect runs of two or more consecutive spaces in a string, so they could be collapsed down to a single space.

MediumValidation

ISO Date Format Checker

Write a regex that checks whether a string follows the YYYY-MM-DD digit layout (four digits, dash, two digits, dash, two digits). It only needs to check the shape, not whether the date is a real calendar date.

MediumParsing

Simple HTML Tag Matcher

Write a regex that detects simple HTML tags like <div>, <p>, or a closing </span>, without worrying about attributes inside the tag.

MediumValidation

24-Hour Time Validator

Write a regex that validates times in 24-hour HH:MM format, where hours must be 00-23 and minutes must be 00-59, with leading zeros required.

HardText Processing

Repeated Word Detector

Write a regex that detects when the same word appears twice in a row separated by whitespace, such as 'the the' or 'is is', a common typo in written text.

HardParsing

Quoted String With Escapes

Write a regex that matches a double-quoted string where escaped quotes (\") inside the string are allowed and don't end the match early, but an unescaped quote in the middle should not be permitted.

HardSecurity

Password Strength Validator

Write a regex that validates a password requiring at least one lowercase letter, one uppercase letter, one digit, one symbol, and a minimum length of 8 characters.

HardText Extraction

Unmarked Number Finder

Write a regex that matches whole numbers in a sentence only when they are NOT immediately preceded by a dollar sign, so plain quantities are found but prices are ignored.

HardParsing

Matching Tag Pair Finder

Write a regex that matches an HTML element only when its closing tag matches its opening tag name, such as <div>...</div>, rejecting mismatched pairs like <span>...</p>.

ExpertValidation

Strict IPv4 Address Validator

Write a regex that validates an IPv4 address, ensuring each of the four dot-separated octets is a real number between 0 and 255, rather than just any string of digits.

ExpertSecurity

Ultra-Strong Password Validator

Write a regex that validates a password between 10 and 24 characters that contains at least one uppercase letter, one lowercase letter, one digit, one symbol, and has no single character repeated three or more times in a row (like 'aaa' or '111').

ExpertText Extraction

Currency-and-Percent-Free Number Finder

Write a regex that matches a whole number only when it is neither immediately preceded by a dollar sign nor immediately followed by a percent sign, isolating plain quantities from prices and percentages in the same sentence.