Skip to content
Regex Runs offline

Regex Cheat Sheet

Every regex token, explained, with copyable examples.

Input

0 chars

Output

0 chars
Ctrl

Questions

Is greedy or lazy matching the default?

Greedy. A quantifier like .* consumes as much as it can and then gives characters back until the rest of the pattern matches. Adding ? makes it lazy, so .*? consumes as little as possible. Lazy matching is usually what you want when extracting content between delimiters.

When should I use a non-capturing group?

Whenever you need grouping for alternation or a quantifier but do not need the captured text. Writing (?:…) instead of (…) keeps your capture group numbers stable and meaningful, which matters as soon as a pattern has more than one group.

Open Regex Tester

Regex Tester

Test regular expressions live, with highlighted matches and groups.

Regex