About RegexLab

Everything you need to test, explore, and understand regular expressions.

What is RegexLab?

RegexLab is a free, instant, browser-based regex playground. Paste a pattern and some text — see matches light up in real time with no server-side account, no rate limits, and no friction.

Whether you're debugging a gnarly email validator, learning regex for the first time, or building a quick test for a production pattern, RegexLab is built for you.

  • Live match highlighting with alternating colors
  • Capture group inspector (numbered & named)
  • Replace mode with substitution preview
  • 15 curated common patterns in the Pattern Library
  • 13 sample strings in the Test String Library
  • Shareable URLs — share any test with one click
  • Supports flags: g, i, m, s

How to Use It

  1. Enter a pattern in the Regex Pattern field (without delimiters).
  2. Paste your test string into the Test String textarea, or pick one from the Test String Library.
  3. Select flags — g (global), i (ignore case), m (multiline), s (dotall).
  4. Choose mode — Match to see highlights, Replace to preview substitutions.
  5. Results update automatically after 500 ms or click Test Pattern.
  6. Click Share to copy a shareable URL with your pattern and text pre-filled.
  7. Browse the Pattern Library for 15 ready-to-use patterns.

Regex Quick Reference

Character Classes

Syntax Meaning Example
. Any character except newline (use s flag for newline too) a.c → "abc"
\w Word character: [a-zA-Z0-9_] \w+ → "hello"
\W Non-word character \W+ → " !"
\d Digit [0-9] \d{4} → "2024"
\D Non-digit \D+ → "abc"
\s Whitespace (space, tab, newline) \s+ → " "
\S Non-whitespace \S+ → "hello"
[abc] Character set — matches a, b, or c [aeiou] → "a"
[^abc] Negated set — anything except a, b, c [^0-9] → "x"
[a-z] Range — any lowercase letter [a-z]+ → "hello"

Anchors

Syntax Meaning
^ Start of string (or line with m flag)
$ End of string (or line with m flag)
\b Word boundary
\B Non-word boundary

Quantifiers

Syntax Meaning
* 0 or more (greedy)
+ 1 or more (greedy)
? 0 or 1 — makes preceding token optional
*? 0 or more (lazy — matches as few as possible)
+? 1 or more (lazy)
{n} Exactly n times
{n,} n or more times
{n,m} Between n and m times

Groups & Lookarounds

Syntax Meaning
(abc) Capturing group — captured as \1, \2…
(?:abc) Non-capturing group
(?P<n>) Named capturing group (Python syntax)
a|b Alternation — matches a or b
(?=…) Positive lookahead — followed by…
(?!…) Negative lookahead — NOT followed by…
(?<=…) Positive lookbehind — preceded by…
(?<!…) Negative lookbehind — NOT preceded by…

Replace Syntax (Python re)

Syntax Meaning
\1 \2 Insert capture group 1, 2…
\g<1> Insert group by number (unambiguous)
\g<name> Insert named capture group

Ready to start testing?

⚡ Open the Playground