Regex Tester

Test, debug, and validate regular expressions with live highlighting, capture groups, replace preview, pattern analysis, and a preset builder — all local to your browser.

Loading tool…

What is a regular expression?

A regular expression is a compact pattern language for describing text. Literal characters match themselves, while metacharacters describe structure: \d for a digit, + for one or more, ^ and $ for the start and end of the input, parentheses for capture groups that pull out the parts you want. The idea comes from 1950s formal language theory and now appears in every programming language, most editors, and tools like grep and sed.

Their power is also their difficulty. Patterns are dense and unforgiving, and small details change everything: greedy versus lazy quantifiers, whether the dot matches newlines, whether matching is case-sensitive, and whether the pattern is anchored. Nested quantifiers can even cause catastrophic backtracking, where a pattern that looks harmless takes exponential time on a crafted input. Testing interactively against real samples is the only reliable way to write them.

Why we built this tool

You write regular expressions for validation, log parsing, bulk find-and-replace, scraping fields out of text, and routing rules — and you almost never get them right first time.

The test data you paste in is the problem: real log lines, real email addresses, real customer records. An online tester that sends every keystroke to a server sees all of it. Ours evaluates the pattern with the browser's own regular expression engine, in your tab, on your data, with no network request at all. Nothing is transmitted or stored, there is no length limit on the test text, and it works offline once loaded.

Tips and common mistakes

  • Test against the awkward cases deliberately: empty strings, unicode, very long input, and text that should not match.
  • Avoid nested quantifiers such as (a+)+, which can cause catastrophic backtracking on crafted input.
  • Regular expression flavours differ between languages; verify a pattern in the environment that will run it.
  • Do not use a regular expression to parse HTML or JSON — use a real parser for structured formats.

Open Regex Tester with a link

Assistants and scripts can open Regex Tester with its input already in the link, after the #, which never leaves your device:

  • #pattern= — the regular expression
  • #subject= — the text to test it against

Example: https://mygadgets.ink/tools/regex-tester/#pattern=...&subject=... · also compressed gz fields and ?url=. How tool links work

Quick start: using Regex Tester

  1. Enter your pattern in the expression field above.
  2. Set the flags you need — global, case-insensitive, multiline.
  3. Paste realistic sample text, including the awkward cases you expect to fail.
  4. Watch the highlighted matches and check the capture groups.
  5. Refine the pattern until it matches everything it should and nothing it should not.

Once the pattern works, Diff Checker helps verify a bulk replacement did what you intended.

Why test instead of guess

Regex fails silently. A pattern intended to validate emails might accept obvious garbage or reject valid addresses, and you would not know until real data hit it in production. Testing against a range of sample inputs — including the edge cases you expect to fail — proves the pattern behaves before you ship it.

Test the failures, not just the successes

The mistake most people make is testing only inputs that should match. A good pattern is defined as much by what it rejects. Build a test set with:

  • Valid inputs that must match.
  • Invalid inputs that must NOT match — the ones that reveal an overly greedy pattern.
  • Edge cases — empty strings, extra whitespace, unusual but legal formats.

Common regex pitfalls

  • Greedy quantifiers. .* grabs as much as possible; use .*? (lazy) when you want the shortest match.
  • Forgetting to anchor. Without ^ and $, a "match" may be a substring buried in a larger string. \d{4} matches four digits anywhere, not "exactly four digits."
  • Unescaped special characters. A literal dot needs \.; a bare . matches any character.
  • Flag confusion. Case-insensitive and multiline flags change behavior dramatically — test with the flags you will actually use.

Common uses

  • Validate formats — emails, phone numbers, postal codes, IDs.
  • Extract data from logs or text.
  • Find and replace with capture groups.
  • Build parsing rules for structured text.

Related Developer Tools

Browse all Developer Tools →