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

Regex Tester can be handed its input by the link that opens it, so the page arrives with the work already done. This is meant for assistants and scripts: if a chatbot, an editor extension, or a command-line agent already holds your content, it can build a link instead of asking you to copy and paste into a box.

The payload rides in the fragment — the part of a URL after the #. Browsers never send the fragment to a server, so anything handed over this way stays on your device exactly as a dropped file would. A link that uses the query string instead is rewritten into the fragment by the page before any analytics or ad script can read the address.

Prefix any field with gz#gzpattern= — to pass it as gzip-compressed base64url, which fits roughly five to ten times more into the same link. Links stay reliable up to about 8,000 characters; past that, chat apps and address bars start truncating them, and the page says so rather than loading half a document.

One exception to the privacy rule: ?url= tells the page to download the input from an address. That request goes from your browser straight to that server — not through ours — but it does leave your device, and it only works if the server allows cross-origin requests.

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

Example: https://mygadgets.ink/tools/regex-tester/#pattern=...&subject=...

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.

Related Developer Tools

Browse all Developer Tools →