Regex Tester

Test a regular expression against your own text and watch every match, capture group, and replacement update as you type. Free, no sign-up, and nothing you paste ever leaves your browser.

//gm

Results

Need a pattern to start from? Open the visual regex generatoror pick one from the pattern library.

In short

A regex tester is a tool that compiles a regular expression and runs it against sample text so you can see what it matches before you put it in code. Build Regex highlights every match in place, breaks each one into its capture groups, and previews replacements — all client-side, so production data stays on your machine.

How to test a regex, step by step

  1. Enter your regular expression. Type the pattern into the expression field between the slashes — for example \d{3}-\d{4}. It compiles as you type and invalid syntax is reported immediately with the engine's own error message.
  2. Choose your flags. Toggle g for every match instead of just the first, i for case-insensitive matching, m so ^ and $ match at each line break, s so the dot also matches newlines, and u for Unicode property escapes.
  3. Paste the text you want to test against. Drop real sample data into the test text panel. Every match is highlighted in place, so you can see exactly which characters the pattern consumed and which it skipped.
  4. Read the match results. The results panel lists each match with its start index, the full matched text, and every capture group — numbered and named — so you can confirm the pattern captures the pieces you expect.
  5. Save or share the result. Copy the pattern to the clipboard, save it to your browser's local storage, or generate a share link that encodes the pattern, flags, and test text in the URL for a colleague.

What the tester shows you

Most regex bugs are not syntax errors — the pattern compiles fine and quietly matches the wrong thing. The tester is built to surface exactly that class of problem:

  • Where each match starts and ends. Highlighting in the text itself makes an over-greedy .* obvious the moment it swallows more than you intended.
  • What each group captured. Numbered and named groups are listed per match, so you can confirm group 2 really is the month before you index into it.
  • How many matches there are. A pattern that finds one match without theg flag and forty with it is the single most common surprise in JavaScript.
  • Why a pattern failed to compile. Errors come straight from the engine — unbalanced parentheses, an invalid class range, an unterminated group.
  • What a replacement will produce. Preview the rewritten output before you run a substitution over real files.

Who this is for

  • Developers validating form input, parsing logs, or writing a search-and-replace across a codebase, who want to confirm a pattern against real samples first.
  • Data and ops engineers extracting fields from semi-structured text — where pasting the sample into a hosted tool would mean sending customer data to a third party.
  • Learners working through the regex course who want a scratchpad to try each new token as they meet it.
  • Anyone using regex in a tool — Notepad++, VS Code find-and-replace, Google Analytics filters, Splunk queries, nginx location blocks — who needs to check a pattern before applying it.

Patterns to try

Paste any of these into the tester above with the g flag enabled:

Common errors and how to fix them

SymptomCauseFix
Only the first match is foundThe global flag is offEnable g, or use a call that returns all matches
The match swallows far too much textA greedy quantifierUse the lazy form .*?, or a negated class such as [^<]*
Invalid input is acceptedThe pattern is not anchoredWrap it in ^ and $
^ and $ ignore line breaksMultiline mode is offEnable the m flag
The dot skips over newlinesDotall mode is offEnable the s flag
"Invalid regular expression" on compileUnescaped metacharacter or unbalanced bracketEscape literal . ? * + ( ) [ ] { } | ^ $ / \ with a backslash
The page hangs on a long inputCatastrophic backtracking from nested quantifiersUn-nest the quantifiers and anchor the pattern so it fails fast

How this compares to other regex testers

Regex101, RegExr, and Debuggex are all good tools, and if you need to test PCRE-, Java-, or Go-specific behaviour, a multi-flavour tester is the right choice. What Build Regex optimises for is different:

What you getDetails
Live match highlightingMatches highlighted in place as you type, with capture groups shaded separately.
Data privacyMatching runs in your browser. No pattern or test text is ever uploaded.
Account requiredNone. No sign-up, no limits, no saved-history paywall.
Visual builderAssemble patterns by clicking blocks instead of typing syntax, then send them to the tester.
Pattern library100+ documented patterns you can load into the tester in one click.
Learning pathA 28-chapter course, graded challenges, and a quiz alongside the tool.

A fuller side-by-side is on the Build Regex vs Regex101page.

Regex Tester Questions

How do I test a regular expression online?

Paste your pattern into the expression field, set the flags you need, then paste your sample text underneath. The tester compiles the pattern on every keystroke and highlights each match directly in the text, with a results panel listing the index, matched text, and capture groups for every match. Nothing is uploaded — the matching runs in your browser using the JavaScript RegExp engine.

Is this regex tester free?

Yes. The Build Regex tester is free with no account, no sign-up, no usage limits, and no ads on the tool itself. Every feature — flags, capture-group inspection, replace and split modes, saved patterns, and share links — is available to everyone.

Does the regex tester send my data anywhere?

No. Pattern compilation and matching happen entirely in your browser using the native RegExp engine. Your pattern and test text never leave your device, which means you can safely paste production logs, customer records, or internal data without it touching a server.

Which regex flavour does this tester use?

It uses the JavaScript (ECMAScript) engine built into your browser, which supports named capture groups, lookahead and lookbehind, Unicode property escapes with the u flag, and sticky matching with the y flag. Core syntax — anchors, character classes, quantifiers, groups, alternation — is identical to Python, Java, PHP, and PCRE, so patterns transfer directly. Language-specific differences are documented in the Python and JavaScript regex guides.

Why does my regex work in the tester but not in my code?

The three usual causes are string escaping, flags, and anchoring. In most languages a pattern written in a normal string needs its backslashes doubled — \d becomes "\\d" — so use a raw string instead where the language offers one. Check that you passed the same flags your test relied on, especially the global flag. And confirm you are using the right call: a search that looks anywhere in the string behaves very differently from a match that is anchored at the start.

Can I test capture groups and named groups?

Yes. The results panel breaks every match into its numbered capture groups, and named groups written as (?<name>...) are listed by name alongside their captured text. That makes it easy to confirm a group is capturing the substring you intend before you wire it into code.

How do I test a replacement, not just a match?

Switch the tester to replace mode and enter your replacement string. Backreferences such as $1 and $<name> are supported, so you can preview exactly what the rewritten text will look like before running the substitution against real data.