Regex Tester

Test and debug regular expressions with real-time matching

Regular Expression

//g

Test Text

Characters: 0 | Lines: 1

Display Settings

Regex Examples

History

About the Online Regex Tester

A regular expression (regex) is a compact pattern that describes a set of strings — useful for validating input, searching text, extracting fields from logs, or find-and-replace across a codebase. Writing one correctly is fiddly, though: a stray quantifier or unescaped bracket silently changes what matches. This tester gives you instant feedback so you can build the pattern iteratively instead of guessing.

Type a pattern and some sample text, and every match is highlighted in real time as you edit. Toggle the common flags — global, case-insensitive, multiline, dotall — and watch the matches update. Capture groups are broken out separately so you can confirm that group 1, group 2, and named groups grab exactly the substrings you expect before you paste the pattern into your code.

Everything runs locally in your browser using the JavaScript regex engine, so nothing you type is uploaded. Because JavaScript, Python (`re`), and Go (`regexp`) share the same core PCRE-style syntax for the constructs people use most — character classes, anchors, quantifiers, alternation, and groups — patterns you validate here will generally behave the same across those languages, with the usual caveats around lookbehind and some Unicode escapes.

How to Test a Regular Expression

Build and debug a regex pattern with live match highlighting.

  1. 1

    Enter your pattern

    Type your regular expression into the pattern field — no surrounding slashes needed. Start simple and add pieces incrementally so you can see what each part matches.

  2. 2

    Paste sample text

    Add representative text into the test area, including examples that should match and edge cases that should not. This is how you confirm the pattern is neither too greedy nor too strict.

  3. 3

    Toggle the flags

    Turn on the flags you need: g to find all matches, i for case-insensitive, m for multiline anchors, s to let the dot match newlines.

  4. 4

    Read the matches and groups

    Matches are highlighted in the sample text and listed below, with each capture group broken out. Verify that every group grabs exactly the substring you expect.

  5. 5

    Copy the finished pattern

    Once the highlights look right, copy the pattern into your JavaScript, Python, or Go code — the core syntax carries over across all three.

Frequently Asked Questions

Which regex flavor does this tester use?

It uses the JavaScript (ECMAScript) regex engine that runs natively in your browser. The core syntax — character classes, anchors, quantifiers, alternation, groups, and backreferences — matches what Python's re module and Go's regexp package use, so most patterns transfer directly. Engine-specific features like lookbehind or certain Unicode property escapes can differ, so verify those in your target language.

What do the flags (g, i, m, s) do?

g (global) finds every match instead of stopping at the first. i (case-insensitive) ignores letter casing. m (multiline) makes ^ and $ match at the start and end of each line rather than the whole string. s (dotall) lets the dot match newline characters too. Toggle them to see how each one changes the highlighted matches.

How do I capture part of a match?

Wrap the part you want in parentheses to create a capture group, e.g. (\d{4})-(\d{2}) captures a year and month separately. Use (?<name>...) for named groups so you can reference them by label. The tester lists each group's captured text next to every match.

Is my pattern or test text sent anywhere?

No. Matching happens entirely in your browser with the built-in RegExp engine. Nothing you type — the pattern or the sample text — is uploaded or stored on any server.

Why is my regex matching too much or too little?

The usual causes are greedy quantifiers (* and + grab as much as possible — add ? like *? to make them lazy), an unescaped special character (escape . * + ? ( ) [ ] { } ^ $ | \ with a backslash when you mean the literal), or a missing global flag so only the first match shows. Build the pattern piece by piece and watch the highlights to pinpoint which token is off.