Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Programming languages

Regular Expressions

Read, write and debug regular expressions: characters and classes, anchors, quantifiers, groups, lookaround, Unicode, flavours and ReDoS safety.

36 lessons to read 11 modules

36 lessons: 36 free with Pro answers.

Examples run with Node.js 24.21.0, quickjs 0.32.0, Python 3.14.8 and Pyodide 314.0.7.

Who it is for

Developers, data analysts and anyone cleaning text, across JavaScript, Python, PCRE and RE2 flavours.

What you will be able to do

  • Explain how a regex engine searches text, and predict the leftmost match a pattern finds
  • Write patterns with literals, escapes, classes, anchors and quantifiers, inside the string literals of real code
  • Capture, name and reuse parts of a match with groups, alternation and backreferences
  • Use lookaround, flags and Unicode properties correctly, and know which flavours support each
  • Port a pattern between JavaScript, Python, PCRE2, RE2 and other flavours without changing what it matches
  • Search, extract and clean text with regex in command-line tools, spreadsheets, SQL and code
  • Validate formats with patterns that state their limits, and choose a parser where a regex falls short
  • Recognise catastrophic backtracking, prevent ReDoS, and handle untrusted patterns and input safely

Revise and practise

Modules and lessons

What the labels mean

Free lesson, Pro answers
the whole lesson is free; the model answers to its interview questions open with a pass
Pro
opens with a Pro, Premium or Ultimate pass

Minutes are reading time.

What a pass opens in this track

72 interview answers. The same pass opens every other track and every Pro tool.

  1. Module 1

    Foundations: what a regex is and how matching works

    What a regular expression is, where patterns run in editors, code, command lines and databases, and how an engine walks the text to find the leftmost match.

    1. What a regular expression is and where it runs Beginner Free lesson, Pro answers: 15 minutes
    2. How an engine finds a match, step by step Beginner Free lesson, Pro answers: 20 minutes
  2. Module 2

    Characters, escapes and character classes

    Literal characters, metacharacters and the dot, writing patterns inside string literals, character classes with ranges and negation, and the shorthand classes.

    1. Literals, metacharacters and the dot Beginner Free lesson, Pro answers: 15 minutes
    2. Writing patterns in code: strings and escaping Beginner Free lesson, Pro answers: 25 minutes
    3. Character classes, ranges and negation Beginner Free lesson, Pro answers: 20 minutes
    4. Shorthand classes for digits, words and spaces Intermediate Free lesson, Pro answers: 25 minutes
  3. Module 3

    Anchors and boundaries

    Start and end anchors, multiline mode and what counts as a line, and word boundaries for whole-word search in each flavour.

    1. Anchors: start, end and multiline mode Beginner Free lesson, Pro answers: 30 minutes
    2. Word boundaries and whole-word search Intermediate Free lesson, Pro answers: 20 minutes
  4. Module 4

    Quantifiers: greedy, lazy and possessive

    Repetition with star, plus, question mark and counted braces, greedy and lazy matching, and possessive quantifiers and atomic groups that never give text back.

    1. Repetition with *, +, ? and {m,n} Beginner Free lesson, Pro answers: 30 minutes
    2. Greedy and lazy quantifiers Beginner Free lesson, Pro answers: 25 minutes
    3. Possessive quantifiers and atomic groups Advanced Free lesson, Pro answers: 25 minutes
  5. Module 5

    Groups, alternation and backreferences

    Capturing and non-capturing groups, named groups in every flavour, alternation and the order of its choices, and backreferences that match the same text again.

    1. Capturing and non-capturing groups Beginner Free lesson, Pro answers: 15 minutes
    2. Named groups across regex flavours Intermediate Free lesson, Pro answers: 10 minutes
    3. Alternation and the order of choices Beginner Free lesson, Pro answers: 20 minutes
    4. Backreferences: matching the same text again Intermediate Free lesson, Pro answers: 20 minutes
  6. Module 6

    Lookaround and advanced constructs

    Lookahead and lookbehind as conditions that consume no text, the lookbehind limits of each flavour, and the conditionals, recursion and extras of PCRE2.

    1. Lookahead: conditions without consuming text Intermediate Free lesson, Pro answers: 20 minutes
    2. Lookbehind and its limits in each flavour Intermediate Free lesson, Pro answers: 20 minutes
    3. Conditionals, recursion and PCRE2 extras Advanced Free lesson, Pro answers: 15 minutes
  7. Module 7

    Flags, modes and Unicode

    Flags and inline modifiers, free-spacing patterns with comments, Unicode code points, case and normalisation, and Unicode properties, scripts and graphemes.

    1. Flags and inline modifiers Beginner Free lesson, Pro answers: 20 minutes
    2. Readable patterns: free-spacing and comments Intermediate Free lesson, Pro answers: 25 minutes
  8. Module 8

    Flavours compared and regex in each language

    How the regex flavours differ, porting a pattern safely, and the regex APIs of JavaScript, Python, PHP, Perl, Go, Java, .NET, Ruby and Rust.

    1. Flavours compared: porting a pattern safely Intermediate Free lesson, Pro answers: 25 minutes
    2. JavaScript regex techniques for text jobs Intermediate Free lesson, Pro answers: 25 minutes
    3. Python regex techniques and the regex module Intermediate Free lesson, Pro answers: 25 minutes
    4. Regex in PCRE2, PHP and Perl Intermediate Free lesson, Pro answers: 20 minutes
    5. Regex in Go, RE2 and re2js Intermediate Free lesson, Pro answers: 25 minutes
    6. Regex in Java, .NET, Ruby and Rust Intermediate Free lesson, Pro answers: 20 minutes
  9. Module 9

    Regex in tools, spreadsheets, web standards and data cleaning

    POSIX patterns in grep, sed and awk, regex in spreadsheets, SQL and analytics tools, patterns in HTML, JSON Schema and config files, and cleaning text data.

    1. grep, sed and awk: regex on the command line Intermediate Free lesson, Pro answers: 25 minutes
    2. Regex in spreadsheets, SQL and analytics tools Intermediate Free lesson, Pro answers: 20 minutes
    3. Regex in HTML, JSON Schema and config files Beginner Free lesson, Pro answers: 20 minutes
  10. Module 10

    Validation patterns and their limits

    Validating numbers, identifiers and dates with patterns that state what they accept, and why emails and URLs need a parser more than a regex.

    1. Validating formats: numbers, IDs and dates Intermediate Free lesson, Pro answers: 20 minutes
    2. Emails, URLs and when to use a parser Intermediate Free lesson, Pro answers: 30 minutes
  11. Module 11

    Performance, ReDoS and security

    Backtracking engines and automata, catastrophic backtracking and ReDoS, writing and measuring fast patterns, untrusted input, and reviewing patterns you did not write.

    1. Backtracking engines versus automata engines Advanced Free lesson, Pro answers: 35 minutes
    2. Catastrophic backtracking and ReDoS Advanced Free lesson, Pro answers: 20 minutes
    3. Writing fast regexes and measuring them Advanced Free lesson, Pro answers: 30 minutes
    4. Regex with untrusted patterns and input Advanced Free lesson, Pro answers: 20 minutes
    5. Reviewing regexes from forums or AI assistants Intermediate Free lesson, Pro answers: 25 minutes

Related tools

Official documentation

More in Programming languages

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.