Testers

Regex Tester

Test a regular expression against a string with live match highlighting.

/ /
Test String
0 matches
Captures

About Regex Tester

Tests a regular expression against a sample string, highlighting matches and capture groups directly against the input so you can see exactly what a pattern does and doesn't catch without running actual code. Regex is notoriously easy to write almost right — a pattern that matches the three examples you tried by hand but fails on the fourth edge case in production. Worth testing both strings that should match and strings that specifically shouldn't, since a pattern that's too permissive is just as much a bug as one that's too strict.

Regex syntax isn't fully identical across languages and engines — a lookbehind or named capture group that works here may need adjusting for a different language's regex implementation, since not every engine supports every feature.

📖 Read more in our Knowledge Base →

Quick Reference

. any char   * 0+   + 1+
? 0 or 1   {n,m} range
[abc] class   [^abc] not
^ start   $ end
\d digit   \w word   \s space
(…) group   (?:…) non-cap
a|b or   \b word boundary
Flags: g=global i=case m=multiline s=dotall

Which regex flavor this is

Patterns run in your browser's JavaScript engine (ECMAScript). Supported flags: g global (always on here so every match is shown), i ignore case, m multiline (^/$ match at line breaks), s dotall (. matches newlines), u Unicode, y sticky.

Differences from other engines

FeatureJavaScriptElsewhere
Named group(?<name>…)Python also accepts (?P<name>…)
LookbehindSupported, any lengthPCRE and Python: fixed length only
Start/end of input^ $ without m\A and \z in PCRE and Ruby, \Z in Python
Possessive a++, atomic (?>…)Not supportedPCRE, Java
POSIX classes [[:digit:]]Not supportedgrep, sed, PCRE

For grep use grep -E (extended) or grep -P (PCRE, GNU only); plain grep needs \+ and \|.

Common mistakes

  • Unescaped dot: example.com also matches exampleXcom. Write example\.com.
  • Greedy matching: ".*" on "a" and "b" matches the whole line. Use ".*?" or "[^"]*".
  • Missing anchors: \d{3} also matches inside 12345. Use ^\d{3}$ or \b\d{3}\b.
  • Catastrophic backtracking: nested quantifiers such as (a+)+$ can take exponential time on a non-matching input and freeze the page or your server (ReDoS).

Useful patterns for admins

  • IPv4 (loose): \b(?:\d{1,3}\.){3}\d{1,3}\b
  • Email address in a log line (loose): [\w.+-]+@[\w-]+(\.[\w-]+)+
  • HTTP status in an access log: " (\d{3})

Testing runs entirely in your browser.