01 · Basics
- literals
- \d \w \s
- wildcard .
- escape
End of the Regex Course
You have completed the 8 modules of the Regex Course — from literal a to lookarounds, named groups, and ReDoS-safe patterns. Below is the map of key concepts and a three-step final challenge that puts them to work together on real-world problems.
Three real-world problems combining all course concepts: validating an Italian IBAN, parsing an Apache log with named groups, and identifying emails to redact in a text. Each exercise requires character classes, quantifiers, anchors, and groups together.
An Italian IBAN is 27 characters long: `IT` + 2 control digits + 1 CIN letter + 5 ABI digits + 5 CAB digits + 12 alphanumeric characters for the account. Build the regex that matches it exactly.
Match an Italian IBAN: IT, 2 digits, 1 uppercase letter, 5 digits, 5 digits, 12 uppercase alphanumeric characters. Exactly 27 characters.
Concatenate: IT, \d{2}, [A-Z], \d{5}, \d{5}, [A-Z0-9]{12}, enclosed in \b.
Solution available after 3 attempts
From a combined Apache log line, extract `ip`, `metodo`, `path` and `status` as named groups.
Extract ip, metodo, path, and status from each line of Apache log. All as named groups.
Start of line ^, IP, two space-separated tokens, date in [...], request in "...", status. Use (?<ip>...), (?<metodo>...), (?<path>...), (?<status>...).
Solution available after 3 attempts
Find every email in the text with named groups `locale` and `dominio`. In a replace callback, you could redact them to `***@dominio`, preserving the domain.
Find every email with two named groups: locale (part before @) and dominio. Use permissive classes.
(?<locale>[\w.+-]+)@(?<dominio>[\w.-]+). In a replace callback (_, locale, dominio) it would return `***@${dominio}`.
Solution available after 3 attempts
A single page with all essential JavaScript regex syntax, ready to keep at hand while programming.
Practice is everything: open the Playground, paste a log or any text file you come across, and try to extract the data you need. Regex are learned by solving concrete problems.