Regex Tester

Test regular expressions with live match highlighting, capture groups, and every JavaScript flag as you type. Both the pattern and your test text are evaluated entirely in your browser, so nothing is uploaded and it's safe to test against real data.

/ /
Enter a pattern to begin.

            

Quick answer

A regular expression is a pattern for finding and extracting text. Type a pattern above, toggle flags like g (all matches) and i (ignore case), and paste text to see matches highlighted with their capture groups. It uses your browser's native JavaScript RegExp engine, so results match Node.js and TypeScript exactly, and nothing you type leaves your device.

How to read the results

Flags explained

Flags change how the whole pattern behaves. The two you'll reach for most are g and i:

Syntax cheat sheet

TokenMatches
.Any character except newline (unless s flag)
\d \w \sDigit, word character, whitespace
\D \W \SThe negation of each (non-digit, etc.)
[abc] [^abc]Any one of a/b/c; or any character except them
[a-z0-9]A character range
* + ?0+, 1+, or 0-or-1 of the preceding token
{2} {2,} {2,5}Exactly, at-least, or between-n-and-m repetitions
^ $Start / end of string (or line with m)
\bWord boundary
(abc) (?:abc)Capturing group / non-capturing group
(?<name>abc)Named capture group
a|bAlternation: a or b
(?=abc) (?!abc)Lookahead / negative lookahead

Remember to escape characters that have special meaning when you want them literally — ., (, ), [, ], {, }, *, +, ?, |, ^, $, and \ — by putting a backslash in front. A literal dot is \., as used in the email example above.

Frequently Asked Questions

What regex flavor does this tester use?

It uses the browser's native JavaScript (ECMAScript) RegExp engine, so what you see here matches exactly how the pattern behaves in JavaScript, Node.js, and TypeScript. Most core syntax is shared with other flavors, but features like lookbehind, named groups, and Unicode property escapes follow the JavaScript specification.

What do the g, i, m, s, u, and y flags do?

g (global) finds all matches instead of just the first; i (ignore case) makes matching case-insensitive; m (multiline) makes ^ and $ match at line breaks; s (dotAll) makes the dot match newlines; u (unicode) enables full Unicode and property escapes; y (sticky) anchors each match at lastIndex. Toggle them with the checkboxes and the results update live.

How do I capture part of a match?

Wrap the part you want in parentheses to create a capture group; it appears as $1, $2, and so on under each match. Use (?<name>...) for a named group, which shows up by name. Use (?:...) for a non-capturing group when you need grouping without capturing.

Is my test text sent to a server?

No. Both the pattern and the test text are evaluated entirely in your browser using the native RegExp engine. Nothing is uploaded, so it is safe to test against real logs or data, and the tool works offline.

Why does my pattern match nothing or throw an error?

If the pattern is invalid — for example an unclosed group or bracket — the status line shows the exact syntax error. If it is valid but matches nothing, check whether you need the g flag for multiple matches, the i flag for case, or the m flag for anchors to work per line. Remember to escape literal special characters like . ( ) [ ] with a backslash.

Can I preview a search and replace?

Yes. Click "Show replace mode" and enter a replacement string to see the rewritten text update live. Capture group references work exactly as they do in JavaScript: $1 and $2 insert numbered groups, $& inserts the whole match, and $<name> inserts a named group. With the g flag set every match is replaced, otherwise only the first.

Can it convert my regex into Python, Go, Java, PHP or C# code?

Yes. Pick a language under "Use this regex in your code" and a ready-to-paste snippet is generated, with the flags translated to that language's equivalent — the JavaScript i flag becomes re.IGNORECASE in Python, (?i) in Go, Pattern.CASE_INSENSITIVE in Java and RegexOptions.IgnoreCase in C#. String quoting is handled per language, so Python uses a raw string, Java doubles its backslashes and Go uses a backtick literal.

What happens if my pattern causes catastrophic backtracking?

Matching runs in a background worker with a one second limit, so a pattern like (a+)+$ against a long string cannot freeze the page. If the limit is hit the worker is terminated, the tool tells you catastrophic backtracking was detected, and where possible it names the construct responsible — typically a quantifier nested inside a group that is itself quantified. The interface stays usable so you can fix the pattern.