HCODX/Regex Tester
100% browser-based · Live highlighting · All JS flags

Regex Tester: free online JavaScript regex debugger

Free regex tester to build and debug JavaScript regular expressions interactively. Matches light up inside the test text as you type, capture groups break out into a table, and replace mode previews rewrites. Powered by your browser's native RegExp engine — your pattern never leaves the page.

Test text
Result

Enter a pattern to see matches.

Pattern & flags
Common patterns library
Find & Replace (plain)
Matches
0
Capture groups
0
Replaced length
Status
Ready
Example

Pattern in, matches out

Every match returns its value, position, and any capture groups. Replace mode runs String.prototype.replace with your replacement string — $1, $2, $&, and named groups all work.

Pattern · /gi
\b(\w+)oxes?\b
Matches
1. "boxing"  at 49  · groups: ["b"]
2. "box"     at 99  · groups: ["b"]
Use cases

What you'll use this for

Regular expressions are the swiss-army knife for text: validation, parsing, extraction, search-and-replace. This tester gives you a tight feedback loop without a console.

Validate input

Sketch a pattern for an email, phone, slug, or postcode and see exactly which inputs slip through.

Extract data

Pull dates, IDs, or URLs out of logs and unstructured text — capture groups appear in a table.

Bulk rewrite

Flip replace mode on and preview a search-and-replace before pasting it into your editor.

Learn regex

Tweak flags one at a time and watch the match set shift. Faster than reading the spec.

Step by step

How to test a regular expression

1

Drop in your text

Paste the sample you want to match against into the left editor. Multi-line is fine — flip the m flag if anchors need to act per line.

2

Write the pattern

Type the regex body into the Pattern field. Skip the surrounding slashes — flags are toggled separately as checkboxes below.

3

Read the matches

Each match shows up highlighted in the test text and listed with its index plus capture groups. Invalid regex turns the result panel red.

4

Try replace mode

Flip Replace mode on, write a replacement (using $1 for the first capture), and preview the rewritten string.

FAQ

Frequently asked questions

As you edit your pattern, CodeMirror's markText API wraps every match range with a translucent blue background directly inside the test-text editor. The marks are cleared and rebuilt on every keystroke, so the highlights stay in sync with whatever you typed.

All JavaScript RegExp flags: g (global), i (case-insensitive), m (multiline — ^/$ match per line), s (dotall — . matches newlines), u (full Unicode), and y (sticky). Toggle each independently with the flag switches.

Yes. Modern Chromium, Firefox, and Safari all support (?<=…) and (?<!…) lookbehinds in JavaScript RegExp. The tester uses your browser's native engine, so anything the browser parses is supported — including named captures (?<name>…).

No. The pattern, test text, and replacement string are evaluated entirely in-browser by the native RegExp constructor. Nothing is sent to a server — close the tab and it's gone.

By default ^ and $ match the start and end of the entire string. To anchor to the start/end of each line, enable the m (multiline) flag. Likewise, . won't cross a newline unless you turn on the s (dotall) flag.

About

About JavaScript regular expressions

Regular expressions are mini-programs for matching patterns in strings. JavaScript's RegExp follows the ECMAScript spec, which today is a near-superset of Perl-compatible regex — with native named captures, lookbehinds, and Unicode property escapes.

Pattern building blocks

  • Character classes\w, \d, \s, plus custom sets like [a-z] or negations [^A-Z].
  • Quantifiers*, +, ?, {2,5}, with lazy variants like +?.
  • Anchors & boundaries^, $, \b for word boundaries.
  • Groups(…) for captures, (?:…) for non-capturing, (?<name>…) for named.

Tips that save hours

  • Test against the worst input you can think of — empty strings, very long lines, lookalike Unicode.
  • Prefer non-capturing groups when you don't need the value; they're cheaper and the table stays tidy.
  • Anchor when you can. An unanchored \d+ on long input is dramatically slower than a bounded one.
Related

Related tools