Regex Tester Online

Test JavaScript regular expressions with real-time matching, capture groups, named groups, and replace. 100% browser-based — no data sent anywhere.

Common patterns:
/ /
0 matches 0 chars

Enter a pattern above and test string to see matches.

Character Classes

.Any character (except newline)
\dDigit [0-9]
\DNon-digit
\wWord char [a-zA-Z0-9_]
\WNon-word char
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]One of a, b, or c
[^abc]Not a, b, or c
[a-z]Char in range a–z

Quantifiers

*0 or more (greedy)
+1 or more (greedy)
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m times
{n,}n or more times
*?0 or more (lazy)
+?1 or more (lazy)

Anchors & Boundaries

^Start of string (or line with m)
$End of string (or line with m)
\bWord boundary
\BNon-word boundary

Groups & Lookarounds

(abc)Capture group
(?:abc)Non-capturing group
(?<n>abc)Named capture group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
a|bAlternation (a or b)

Flags

gGlobal — find all matches
iIgnore case
mMultiline (^ and $ per line)
sDot matches newlines too
uUnicode mode

Replace Back-references

$1, $2Numbered capture group
$<name>Named capture group
$&Entire matched string
$`Text before match
$'Text after match

How to Use

  1. Enter your regular expression pattern in the pattern field (without slashes). The pattern updates matches in real time.
  2. Toggle flags on the right of the pattern field: g (global — find all), i (ignore case), m (multiline), s (dot-all), u (unicode).
  3. Type or paste your test string in the text area. Matches and their positions appear instantly below.
  4. Switch to the Replace tab to do find-and-replace with back-references like $1, $2, or $<name> for named groups.
  5. Use the Cheatsheet tab for a quick reference of regex syntax — character classes, quantifiers, anchors, lookarounds, and flags.

About This Tool

Regular expressions (regex) are powerful pattern-matching sequences used to search, validate, extract, and transform text. JavaScript's built-in RegExp engine — which powers this tester — supports the full ECMAScript regex standard including named capture groups ((?<name>...)), lookbehind assertions ((?<=...)), Unicode property escapes (\p{L} with the u flag), and sticky matching. This tool runs every match operation entirely in your browser using native JavaScript — your test strings and patterns never leave your device. It is ideal for debugging API response parsing, building form validation, writing log analysis scripts, or learning regex syntax with immediate feedback. Use the common patterns quick-load bar above the pattern field to get started with frequently needed patterns like email addresses, URLs, IPv4 addresses, dates, and UUIDs.

Frequently Asked Questions

Why do I get an “Invalid regular expression” error?

This happens when the pattern contains a syntax error. Common causes include unmatched or unescaped parentheses, an invalid quantifier like {,3}, unescaped forward slashes inside a character class, or an invalid escape sequence such as \q. Make sure to escape literal dots with \., backslashes with \\, and parentheses with \( when you need them as literal characters rather than metacharacters.

How do I capture groups and use them in the Replace tab?

Wrap the part of the pattern you want to capture in parentheses: (\d{4})-(\d{2})-(\d{2}) captures year, month, and day as groups 1, 2, and 3. In the Replace field, reference them with $1, $2, $3. For named groups like (?<year>\d{4}), use $<year> in the replacement. Use $& to insert the entire matched substring.

What is the difference between the g and m flags?

The g (global) flag makes the engine find all non-overlapping matches in the input string instead of stopping after the first one. The m (multiline) flag changes the meaning of ^ and $ — without m they match the start and end of the entire string; with m they match the start and end of each individual line. You often combine both flags when processing multi-line text with line-based patterns.

Does this tester support lookaheads and lookbehinds?

Yes. Modern JavaScript (V8 engine) supports all four zero-width assertions: positive lookahead (?=...), negative lookahead (?!...), positive lookbehind (?<=...), and negative lookbehind (?<!...). For example, \w+(?=\.js\b) matches filenames immediately before a .js extension, and (?<=\$)\d+(\.\d{2})? matches a dollar amount after the $ sign without including the sign in the match.

Related Tools