UUsefulCrate Your files never leave your browser

Home › Tools › Regex Tester

Regex Tester

A scratch pad for regular expressions: enter a pattern and flags, paste sample text, and see every match and capture group highlighted in real time. JavaScript flavour — the same engine your browser and Node.js use.

100% private — everything runs in your browser, nothing is ever uploaded.

What this tool does

A validation rule rejects a perfectly reasonable email address, and the pattern is a wall of backslashes nobody wants to decode in their head. A regular expression is much easier to reason about when you can see what it matches. This tool is a live scratch pad: enter a pattern, choose the g, i and m flags, paste sample text, and see every match highlighted with capture groups listed underneath. It uses the JavaScript engine, the same one your browser and Node.js use, so behaviour here matches what your front-end code will do. It is useful for checking a pattern against edge cases before committing it, untangling a pattern from a legacy config, or learning what a quantifier actually consumes by trying it on a few lines of sample data.

How to use it in three steps

  1. Type the pattern and choose the flags you need: g for all matches, i for case-insensitive, m for line anchors.
  2. Paste sample text that includes both the cases you want to match and the cases you want to exclude. Matches highlight instantly as you edit.
  3. Read the capture groups listed under each match. If a pattern matches more than intended, narrow it and watch the highlighting shrink before using it in code. Add one deliberately invalid example to your sample text, so you can see that the pattern excludes it too.

Questions people ask

Why does the same pattern behave differently in Python or grep?

Regular expression dialects differ. This tester uses JavaScript syntax, so it matches browser and Node.js behaviour; features such as lookbehind, named groups and Unicode property escapes may differ elsewhere.

What does a greedy match mean in practice?

A greedy quantifier takes as much as it can while still allowing the rest of the pattern to match, which often swallows more text than expected. Add a lazy quantifier or a narrower character class and check the highlighted matches again.

Can I test against very long input?

It runs in your browser, and highlighting thousands of matches can slow the page down. Start with a short representative sample, then extend the text once the pattern is right.

Why does my pattern with the g flag behave differently?

The global flag collects every match instead of stopping at the first one, and it also makes some methods advance a lastIndex cursor between calls. Testing here with the same flags your code uses is the only reliable way to reproduce that behaviour.

Privacy: Patterns and sample text are evaluated by your browser's own JavaScript engine in this tab, meaning log lines, personal data and internal strings are never uploaded, logged or stored remotely.

How to use it

  1. Type your pattern and choose flags (g, i and m).
  2. Paste the text you want to test against.
  3. Matches are highlighted instantly; capture groups are listed under each match.

Why it stays private

Patterns often carry fragments of real data — logs, tokens, customer strings. Testing runs on your machine with your browser's own regex engine, so the sample text stays private.

Questions

Which regex flavour is this?

JavaScript (ECMAScript), because the tool runs in your browser. It matches what you get in Node.js and in JavaScript code generally. Lookbehind needs a recent browser; PCRE-only features like \K or recursion are not available.

Why do my matches highlight strangely with the g flag missing?

Without the g flag only the first match is reported — that is correct JavaScript behaviour, not a bug. Add g to find all matches.

Is my pattern or text stored anywhere?

No. The page holds it in memory, highlights it and forgets it when you close the tab. There is no server component at all.

Why is my regex not matching?

In rough order of frequency: a missing g flag so only the first match shows; an unescaped special character — a literal dot must be \. and a literal star \*; greedy quantifiers swallowing more than intended, fixed with ? after them; and line-anchor confusion, where ^ means the start of the whole string unless the m flag makes it match at every line break. Test each part alone, then combine.

What does a capture group do, and what about (?:...)?

Parentheses remember whatever matched inside them, and each group is listed separately under its match — (\d{4})-(\d{2}) hands you the year and the month as two values you can reference as $1 and $2 in replacement strings. Add ?: to make a group non-capturing: it still groups for precedence, it just does not take a slot, which keeps numbering tidy when you only want one or two values out of a long pattern.

Related tools

JSON Formatter & Validator

Format, validate and minify JSON with clear error messages.

Base64 Encoder & Decoder

Encode and decode text as Base64, UTF-8 safe.

URL Encoder & Decoder

Percent-encode or decode URLs and query strings.

← All tools