🔍

Regex Lab

Build and debug regular expressions with live match highlighting, a plain-English breakdown, capture group inspection, replace preview, and code generation for eight languages.

Utilities v1.0.0 33 uses
Expression
/ / g
Test string

                

            

Contact

Web & data

Code

Characters

. Any character except newline
\d Any digit, 0 to 9
\D Any character that is not a digit
\w Word character: letter, digit or underscore
\W Any character that is not a word character
\s Any whitespace: space, tab, newline
\S Any character that is not whitespace
[abc] Any one of a, b or c
[^abc] Any character except a, b or c
[a-z] Any character in the range a to z

Quantifiers

* Zero or more
+ One or more
? Zero or one — makes it optional
{3} Exactly three
{2,} Two or more
{2,5} Between two and five
*? Zero or more, lazy — as few as possible
+? One or more, lazy

Anchors & groups

^ Start of the string, or of a line with m
$ End of the string, or of a line with m
\b Word boundary
\B Not a word boundary
(…) Capture group
(?:…) Group without capturing
(?<name>…) Named capture group
a|b Either a or b

Lookaround

(?=…) Followed by — lookahead
(?!…) Not followed by — negative lookahead
(?<=…) Preceded by — lookbehind
(?<!…) Not preceded by — negative lookbehind
\1 Backreference to capture group 1

About This App

A working environment for regular expressions rather than a one-shot tester. Type a pattern and see every match highlighted in your sample text as you type, with capture groups broken out per match and named groups resolved. The explain panel walks the pattern token by token in plain English, so you can see exactly what each piece does — useful when you inherited the expression rather than wrote it. A replace tab previews substitutions live, including $1 style backreferences. When the pattern is right, generate ready-to-paste code for JavaScript, PHP, Python, Java, C#, Go, Ruby, or a grep command. Includes a library of vetted patterns for emails, URLs, dates, IPs and more, a full token cheatsheet, match timing to catch catastrophic backtracking, and autosave so your work survives a refresh. Runs entirely in your browser — nothing is uploaded.

How to Use

  1. 1 Type your pattern into the expression bar and set flags with the toggles
  2. 2 Paste or type sample text underneath — matches highlight as you type
  3. 3 Open the Matches tab to inspect each match and its capture groups
  4. 4 Open Explain to read the pattern broken down token by token
  5. 5 Use the Replace tab to preview substitutions, with $1 backreferences
  6. 6 Pick a language in Code to copy a ready-made snippet
  7. 7 Load a starting point from the Library, or keep a pattern you like
  8. 8 Work is saved locally, so a refresh will not lose it
ESC