Regex Tester – Free Online Tool | Awesome Toolkit

Regex Tester

Test regular expressions live against custom input. Highlights matches and displays capture groups.

By Marshkalk

Highlighted Matches

How to use the Regex Tester

  1. Enter your regular expression pattern in the Pattern field.
  2. Enable flags as needed: g finds all matches, i ignores case, m makes ^ and $ match line boundaries, s makes . match newlines.
  3. Paste your test string, matches are highlighted in real time and capture groups are listed below.

JavaScript regex syntax quick reference

TokenMeaning
.Any character except newline
\d / \DDigit / non-digit
\w / \WWord character [a-zA-Z0-9_] / non-word
\s / \SWhitespace / non-whitespace
^ / $Start / end of string (or line with m flag)
\bWord boundary
+One or more (greedy)
*Zero or more (greedy)
?Zero or one (optional)
{n,m}Between n and m repetitions
[abc]Character class (any of a, b, c)
[^abc]Negated class (anything except a, b, c)
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
a|bAlternation (a or b)

Common regex patterns

  • Email address: [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
  • URL: https?://[^\s/$.?#][^\s]*
  • IP address: \b(?:\d{1,3}\.){3}\d{1,3}\b
  • Date (YYYY-MM-DD): \d{4}-\d{2}-\d{2}
  • Hex color: #(?:[0-9a-fA-F]{3}){1,2}\b

Greedy vs lazy matching

By default, quantifiers (+, *, {n,m}) are greedy: they match as much as possible. Add ? after the quantifier to make it lazy (match as little as possible): +?, *?, {n,m}?. Example: <.+?> matches individual HTML tags instead of everything from the first < to the last >.

Engine differences: JavaScript vs PCRE vs RE2

Regex syntax looks similar across engines but behaves differently in key areas. A pattern that works in your browser may fail in PHP, Python, or Go:

FeatureJavaScript (this tool)PCRE (PHP, Python, Perl)RE2 (Go, Rust)
Lookbehind (?<=...)Fixed-length (ES2018+)Variable-lengthFixed-length only
Backreferences YesYesNo
Atomic groups (?>...)NoYesNo
Unicode classes \p{L}Yes (with u flag)YesYes (default)
\d matches Unicode digitsNo (ASCII only without u)Yes (default in PCRE2)No (ASCII only)

5 common pitfalls

  • Catastrophic backtracking: A pattern like (a+)+b on a long string of 'a' with no 'b' triggers exponential backtracking and can freeze your app. Avoid nested quantifiers on overlapping patterns. Always test with long, non-matching input.
  • \d and Unicode digits: Without the u flag, \d only matches ASCII 0-9, not Arabic-Indic (٠-٩) or other Unicode digit forms. Add u and use \p{N} if you need all Unicode digits.
  • ^ and $ without the m flag: By default, ^ and $ match the start and end of the whole string. For per-line anchors on multi-line input, add the m flag.
  • Greedy match eating the whole string: <.+> on <b>text</b> matches from the first < to the last >. Use lazy <.+?> to match one tag at a time.
  • Unescaped dots in domain patterns: The dot matches any character. example.com also matches exampleXcom. Escape literal dots: example\.com.