Regex Tester - Test Regular Expressions with Live Matches

Test JavaScript regular expressions against sample text and see every match, its position, and its capture groups instantly.

Enter a pattern, pick your flags, paste some test text, and click the test button. Everything runs in your browser using the native JavaScript regex engine — nothing is uploaded.

Regex Tester - Test Regular Expressions with Live Matches
Test JavaScript regular expressions against sample text and see every match, its position, and its capture groups instantly.

Quick reference: common regex tokens

A cheat sheet of the tokens you will reach for most often when writing JavaScript regular expressions.

TokenMeaning
.Any single character except a line break (unless the s flag is set)
\d / \DA digit 0–9 / anything that is not a digit
\w / \WA word character (letter, digit, underscore) / a non-word character
\s / \SA whitespace character / a non-whitespace character
^ / $Start of string / end of string (start and end of each line with the m flag)
\bA word boundary — the edge between a word character and a non-word character
* + ?Zero or more / one or more / zero or one of the preceding item
{n} {n,} {n,m}Exactly n / at least n / between n and m repetitions
[abc] [^abc]Any character in the set / any character not in the set
(x)Capturing group — the matched text is stored and shown in the groups column
(?:x)Non-capturing group — groups the pattern without saving the match
a|bAlternation — matches either a or b
(?=x) (?!x)Lookahead: the next text must (or must not) match x, without consuming it

About the regex tester

Regular expressions are one of the most powerful text-processing tools in a developer's toolbox, and also one of the easiest to get subtly wrong. This regex tester lets you develop and debug JavaScript regular expressions interactively: type a pattern, choose flags, paste sample text, and immediately see how many times the pattern matches, exactly where each match starts, what each capturing group extracted, and how the matches sit inside your text thanks to inline highlighting. The tool uses the regular expression engine built into your own browser, which means the behaviour you see here is precisely the behaviour you will get in production JavaScript, TypeScript, and Node.js code. That matters because regex dialects differ: constructs like lookbehind, named groups, or unicode property escapes behave differently across languages, and a pattern tuned for PCRE or Python will not always translate directly. Testing against the real JavaScript engine removes that guesswork. All five of the most commonly used flags are available as checkboxes. The global flag makes the engine continue past the first match and report every occurrence, which is what you usually want when counting or extracting values. The ignore-case flag makes letters match regardless of case. The multiline flag changes the caret and dollar anchors so they match at the start and end of each line instead of the whole string. The dotAll flag lets the dot token cross line breaks, and the unicode flag switches the engine into full code-point mode so emoji and characters outside the Basic Multilingual Plane are treated as single characters. When a pattern fails to compile — an unclosed group, a stray quantifier, a bad range — the tester surfaces the engine's own syntax error message instead of failing silently, so you can pinpoint the exact problem. Zero-length matches are handled safely, and a generous cap protects the page from runaway patterns. Everything happens locally in your browser. The pattern and the test text are never transmitted to a server, so it is safe to paste logs, configuration files, or other sensitive material. Typical uses include building validation patterns for forms, extracting fields from log lines, crafting search-and-replace expressions for editors, and simply learning how a token behaves before committing it to code. Combine the results table with the quick-reference cheat sheet below to iterate quickly toward a correct, readable pattern.

Regex tester examples

A few classic patterns and what they find in ordinary text.

PatternWhat it matchesNotes
[\w.+-]+@[\w-]+\.[\w.]+Email-like addresses such as ana@example.comA pragmatic email matcher for extraction — real address validation needs more than a regex.
\bcat\bThe word cat on its own, but not concatenateWord boundaries stop partial-word hits; add the i flag to also catch Cat and CAT.
(\w+)-(\w+)Hyphenated pairs like user-name, with each half capturedThe two capturing groups appear in the groups column, ready for a replace template.
^\s+|\s+$Leading and trailing whitespace on the stringWith the g and m flags this trims every line — a common cleanup pattern.

How to use the regex tester

  1. Type or paste your regular expression into the pattern field, without surrounding slashes.
  2. Tick the flags you need — global is on by default so every occurrence is reported.
  3. Paste the sample text you want to search into the test text box.
  4. Click Test to compile the pattern and run it, then review the match table, capture groups, and highlighted text.
  5. Refine the pattern and test again until the highlighted output is exactly what you expect.

Regex tester FAQ

Which regex flavour does this tester use?
It uses the native JavaScript (ECMAScript) engine in your browser — the same one that runs in Node.js and web apps. Patterns verified here behave identically in JavaScript code, but may need adjustments before use in Python, PCRE, or Java.
Do I need to wrap the pattern in slashes?
No. Enter only the pattern body, exactly as you would pass it to new RegExp(). Flags are chosen with the checkboxes rather than appended after a closing slash.
Why is only the first occurrence reported?
You probably unticked the g (global) flag. Without it, the JavaScript engine stops after the first hit. Tick g and run the test again to list every occurrence with its position.
What are capture groups and where do I see them?
Parentheses in a pattern create capturing groups that store the sub-parts of every hit. The results table shows a groups column listing what each group extracted, which is handy when building replace templates or parsing structured strings.
Is my text sent to a server?
Never. Compilation and matching happen entirely inside your browser tab, so you can safely test against logs, tokens, or private documents. Closing the page discards everything.
Why does my pattern show a syntax error?
Common causes are an unclosed parenthesis or bracket, a quantifier with nothing before it, or an escape that the unicode flag rejects. The message shown comes straight from the JavaScript engine and names the offending construct.