Free Tools Grid

Regex Tester

Developer Tools

Build and test regular expressions live in your browser. Match highlighting, named and positional capture groups, replace mode, and a built-in cheatsheet for the patterns you forget.

Runs entirely in your browser
Loading tool...

About Regex Tester

Regular expressions are the universal pattern-matching language across every modern programming environment — JavaScript, Python, Go, Ruby, grep, ripgrep, your editor's find-and-replace, and a hundred other places. But the syntax is dense, edge cases are subtle, and getting one right by reading the docs alone is rough. A live tester closes the feedback loop: write the pattern, see exactly what it matches, see what the capture groups grab, see what the replacement produces.

This tester uses the browser's native `RegExp` engine — the same one your JavaScript code runs against, so what works here works in production. Toggle any combination of the six flags (g, i, m, s, u, y), inspect positional ($1, $2…) and named (?&lt;n&gt;) capture groups, and switch to Replace mode to preview replacements with `$&`, `$1`, or `$<name>` backreferences. Invalid patterns surface the parser's error message instead of breaking the page. The cheatsheet sidebar covers the tokens you reach for most.

How to use

  1. 1

    Type your pattern

    Enter the regex pattern (without enclosing slashes) into the Pattern field. The preview shows the full /pattern/flags slash form below.

  2. 2

    Pick flags

    Tick any of g (global), i (case-insensitive), m (multiline), s (dotall), u (unicode), y (sticky). Hover each chip to see what it does.

  3. 3

    Paste a test string

    Drop your input into the Test string area. Matches are highlighted in amber as you type, and a table below lists each match with its position and capture groups.

  4. 4

    Switch to Replace mode for substitutions

    The Replace tab adds a Replacement field. Use $& for the whole match, $1 / $2 for positional groups, or $<name> for named groups.

  5. 5

    Read parser errors

    If your pattern is invalid (unbalanced brackets, bad escape, etc.) the engine's own error message appears under the pattern field — usually telling you exactly what's wrong.

Examples

Find repeated adjacent words

A classic regex — backreference $1 matches the same word again.

Input

Pattern: \b(\w+)\s+\1\b
Text: Hello hello world world.

Output

2 matches: 'Hello hello', 'world world'

Extract emails (basic)

A simple email pattern — good for quick extraction, not for strict RFC validation.

Input

Pattern: [\w.+-]+@[\w-]+\.[\w.-]+
Text: Reach hello@example.com or admin+test@sub.example.org

Output

2 matches

Replace with capture group

Wrap each matched word in brackets using $&.

Input

Pattern: \b\w+\b
Replacement: [$&]
Text: hello world

Output

[hello] [world]

Frequently asked questions

Does this match the regex flavor of language X?+

It uses JavaScript's RegExp engine. JavaScript regex is very similar to PCRE (Python, PHP, Perl) and ECMAScript-spec but has a few differences: no atomic groups, no recursion, no lookbehind in older browsers (modern Chrome/Edge/Firefox/Safari support it now). For most patterns, behavior matches Python's `re` module.

Why isn't my pattern matching anything?+

Common causes: forgot the g flag (without it only the first match is found in some contexts), an unescaped special character (`.`, `(`, `[`, `{`, `\`, `|`, etc.), or anchoring with ^/$ that requires the m flag to work per-line.

What's the difference between greedy and lazy quantifiers?+

Greedy (`*`, `+`, `?`, `{n,m}`) matches as much as possible. Lazy (`*?`, `+?`, `??`, `{n,m}?`) matches as little as possible. For HTML tag content like `<.*>` (greedy) matches the whole line if there are multiple tags; `<.*?>` (lazy) matches one tag at a time.

Are my pattern and test string sent anywhere?+

No. The browser's RegExp engine runs locally. Nothing is transmitted.

Why is my regex really slow on certain inputs?+

Catastrophic backtracking. Patterns with nested quantifiers (e.g. `(a+)+`) can take exponential time on certain inputs. Symptom: the tester freezes for a few seconds. Fix by simplifying the pattern, using atomic-style constructs, or restructuring the regex to avoid ambiguity.

How do I match across newlines?+

Use the s (dotall) flag — it makes `.` match newline characters. Without s, `.` matches anything except `\n`. The m (multiline) flag is different: it changes `^` and `$` to match line boundaries, not the entire string boundaries.

How do I use named capture groups?+

Define with `(?<name>pattern)`. In Replace mode, reference with `$<name>`. In code, the matches object has a `.groups` property: `match.groups.name`.