Regex Tester

Test, validate, and debug regular expressions instantly in your browser with live highlighting and match details.

Enter a regular expression above to get started.

Add some test text above to see matches highlighted live.

Statistics

Total matches
0
Current match
-
Regex length
0
Text length
0
Capture groups
0
Regex cheat sheet
.
Any character except a line break (unless the s flag is on).
*
Zero or more of the previous token.
+
One or more of the previous token.
?
Zero or one of the previous token. Also marks a quantifier as lazy, e.g. *?.
[ ]
A character class - matches any one character inside, e.g. [abc] or [a-z].
[^ ]
A negated character class - matches any one character NOT listed, e.g. [^0-9].
( )
A capturing group - remembers the matched text for use in results or as $1, $2... in a replacement.
(?: )
A non-capturing group - groups a pattern without remembering the match.
{ }
A quantifier range, e.g. {3}, {2,5}, or {2,}.
^
Anchors to the start of the string (or line, with the m flag).
$
Anchors to the end of the string (or line, with the m flag).
|
Alternation - matches whatever is on either side, like cat|dog.
\d \D
Any digit, or any non-digit.
\w \W
Any word character (letter/digit/underscore), or any non-word character.
\s \S
Any whitespace character, or any non-whitespace character.
\b \B
A word boundary, or a position that is NOT a word boundary.
(?= )
Lookahead - matches only if followed by this pattern, without consuming it.
(?! )
Negative lookahead - matches only if NOT followed by this pattern.
(?<= )
Lookbehind - matches only if preceded by this pattern. Supported in all current major browsers.
(?<! )
Negative lookbehind - matches only if NOT preceded by this pattern.
\.
A backslash escapes a special character, making it literal - \. matches an actual period.

Whether you're debugging a validation pattern, extracting data from log lines, or just trying to remember what \b does, this tool tests, highlights, and explains regular expressions live as you type - entirely in your browser, using the same RegExp engine your code actually runs on, with nothing ever uploaded.

What regular expressions are

A regular expression (regex) is a small pattern language for describing text to search for, validate, or replace - instead of matching one exact string, a pattern like \d+ matches "one or more digits" wherever they appear. Every mainstream programming language, including JavaScript, ships a built-in regex engine; this tool runs your pattern through the browser's own, so the behavior you see here is exactly what you'd get in real code.

Regex flags, explained

Flags change how a pattern is applied, not what it matches character-by-character. Global (g) finds every match instead of stopping at the first; Ignore Case (i) makes letters match regardless of case; Multiline (m) makes ^ and $ match at the start and end of each line, not just the whole string; Dot All (s) lets . also match line breaks; Unicode (u) makes the engine treat the pattern as full Unicode code points instead of raw 16-bit code units (this matters for emoji and other characters outside the Basic Multilingual Plane); and Sticky (y) anchors matching to exactly the last match's ending position, with no scanning forward to find the next one.

Capturing groups

Wrapping part of a pattern in parentheses, like (\d{4})-(\d{2}), creates a capturing group - it remembers the text that part matched, numbered left to right starting at 1 (group 0 is always the entire match). Captured text can be reused in a replacement string as $1, $2, and so on, or read programmatically from the match result. Prefixing with ?:, like (?:abc), groups a pattern without capturing it - useful when you need grouping (for a quantifier or alternation) but don't need the matched text back.

Common regex mistakes

  • Forgetting the g flag, then being confused why only one match shows up.
  • Using . when you mean a literal period - . matches ANY character unless escaped as \.
  • Greedy quantifiers (.*) matching far more than intended - a lazy .*? often gives the expected, narrower match instead.
  • Forgetting to escape regex-special characters in literal text, like $5.00, where $ and . both need a backslash to be literal.
  • Assuming \d, \w, and similar shorthand classes match Unicode letters/digits the same as ASCII ones - without the u flag, matching behaves in terms of UTF-16 code units.

Performance tips

  • Avoid nested quantifiers on overlapping character sets, like (a+)+ - these can trigger "catastrophic backtracking," where matching time explodes exponentially on certain inputs. This is a property of the regex engine itself (JavaScript's included), not something this tool can prevent - if a pattern here seems to hang, that's very likely the cause.
  • Anchor patterns with ^/$ when you mean to match the whole string - it lets the engine fail fast instead of trying every starting position.
  • Prefer specific character classes ([0-9]) over broad ones followed by heavy backtracking-prone quantifiers when performance matters on large text.

Frequently asked questions

Why does my pattern only find one match?

Turn on the g (Global) flag - without it, JavaScript's RegExp only ever reports the first match it finds, which is exactly what this tool reproduces.

Do I need to type the slashes around my pattern?

No - typing just \d+ works fine. If you paste a full /\d+/gi literal (slashes and all), the slashes are stripped automatically and any trailing flags are applied to the flag checkboxes for you.

Why is lookbehind not matching in my browser?

Lookbehind ((?<=...) and (?<!...)) is supported in all current versions of Chrome, Edge, Firefox, and Safari, but only relatively recently in Safari's case - an older browser version is the most likely explanation if it seems unsupported.

Is my pattern or test text uploaded anywhere?

No - matching, highlighting, and replacing all run locally using your browser's own RegExp engine; nothing is sent anywhere.

Why did the page freeze on my pattern?

Almost certainly catastrophic backtracking (see Performance tips above) - a small number of patterns and inputs can make ANY regex engine take an extremely long time, which is an inherent property of backtracking-based matching, not a bug in this tool. Reloading the page will recover it.

Related tools

Browse the rest of the Developer tools on NeatSize.

Runs entirely in your browser - nothing you enter or upload is sent to a server.