How To Guide

How to Test Regex Online — Free Regex Tester with Live Match Highlighting

Test regular expressions against sample text with live match highlighting, capture groups, and flag support (g, i, m, s, u). Works with JavaScript, PCRE, and POSIX flavors.

Regex is write-only code

Most regex bugs come from writing a pattern that looks correct and never testing it against edge cases. A live tester fixes this: you see every match, every capture group, and every miss in real time. The regex tester highlights matches in the sample input and shows which part of the input each capture group consumed.

Flavors differ — pick the right one

FlavorUsed byKey differences
JavaScript (ECMAScript)Browsers, Node.js, most lintersNo lookbehind in older engines; no named refs in some
PCREPHP, nginx, most CLI toolsFull lookbehind, recursion, conditionals
POSIX EREgrep -E, awk, sed -ENo lookaround; simpler syntax
Python rePythonPCRE-like but no recursion
Go regexpGoRE2 — no backrefs, guaranteed linear time

The flags

  • g — global (find every match, not just the first)
  • i — case-insensitive
  • m — multiline (^/$ match start/end of each line)
  • s — dotall (. matches newlines)
  • u — Unicode (treats input as UTF-16 code points, enables \p{...})

Common patterns worth memorizing

  • Email (simple): [^\s@]+@[^\s@]+\.[^\s@]+ — catches 99% of valid addresses
  • URL: https?://\S+ — trust but validate separately
  • Digits only: ^\d+$
  • IPv4: ^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
  • UUID: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
  • Hex color: ^#([0-9a-f]{3}){1,2}$
  • Leading/trailing whitespace: ^\s+|\s+$

Greedy vs lazy quantifiers

.* matches as much as possible. .*? matches as little as possible. The difference matters hugely: <.*> against <a>b</a> matches the whole string; <.*?> matches just <a>. HTML parsing bugs almost always involve picking the wrong one. (For real HTML, use a parser — regex is the wrong tool.)

When to stop using regex

If your pattern has more than three nested groups or more than one lookaround, you're probably reaching for the wrong tool. Parsing structured data (HTML, JSON, YAML) should use a parser. For complex text analysis, consider a tokenizer + state machine. For JSON-specific querying, use JSONPath tester.

Related tools

For comparing two strings' text (not regex), text compare. For diffing code, diff checker.

Featured Tools

Try these free tools directly in your browser — no sign-up required.

how to test regex online regex tester regular expression tester regex debugger regex validator

Explore 300+ Free Tools

Utilko has tools for developers, writers, designers, students, and everyday users — all free, all browser-based.