Skip to content

Regex tester

Write a pattern and see what it matches as you type.

/ /gi

Your files are open only in this tab. Nothing is uploaded.

Matches

No matches.

Uses JavaScript's built-in RegExp engine, matching Node.js and modern browsers.

How to use Regex tester

  1. Enter your pattern and flags. Type an expression inside the Pattern field and toggle g, i, m, s, u, or y pills to adjust matching rules.
  2. Add sample text and inspect matches. Paste strings into Test text to see live highlights, total match count, and capture groups in the Matches sidebar.
  3. Preview replacements if needed. Check Replace, enter a template using $1, $&, or $<name>, and copy the generated Result output.

Everything runs in this browser tab. Nothing you paste or open is uploaded or logged, so it's safe for keys, tokens and private data.

How do JavaScript regex flags change matching behavior?

Flags appended after the closing slash alter whether an expression stops after one hit, ignores letter casing, spans multiple lines, or treats Unicode code points as whole characters. When you test regular expressions in your browser, toggling the six flag pills below Pattern updates /pattern/flags live and reruns the match worker after an 80 ms debounce.

Every evaluation runs locally inside your browser tab without uploading logs, API keys, or configuration snippets to a remote server. The default (\w+)@([\w.-]+)\.(\w+) pattern and sample addresses let you inspect live highlighting and capture groups immediately upon opening the page.

Global, case-insensitive, multiline, and dotAll toggles

The default g (all matches) and i (ignore case) flags find every occurrence regardless of capitalization. Turning off g stops at the first match in both Matches and Replace, which is useful when testing single-record extraction.

Enabling m (^ $ per line) makes ^ and $ anchor at every line break instead of only the start and end of the entire Test text block. Enabling s (. matches newline) lets the dot wildcard match \n characters across multi-line log entries, as detailed in the MDN JavaScript Regular Expressions Guide.

Unicode u mode and sticky y anchors

Enabling u (Unicode) switches the engine to full code-point matching so emoji and \p{Letter} property escapes work accurately. Even when u is unchecked, the highlighter clamps slice boundaries so non-Unicode matches never split a UTF-16 surrogate pair in Test text.

The y (sticky) flag forces matching to continue strictly from lastIndex without skipping unmatched characters. If you write schedule expressions alongside log filters, you can also use cron expression explainer in your browser to verify recurring job timing.

Inspecting numbered and named capture groups in Matches

Parentheses inside a pattern record substrings for extraction, validation, and downstream replacement. As you type, the Matches panel lists every hit with its zero-based character offset (at <index>) and expands any captured subgroups underneath.

Reading $1, $2, and (?…) captures

Numbered groups appear in left-to-right opening-parenthesis order as $1, $2, and so on. Named groups written as (?<user>\w+) display their exact label instead of a number, making complex URL or log parsers much easier to audit.

Both numbered and named captures follow the ECMA-262 RegExp Objects Specification, which also governs positive and negative lookbehind assertions like (?<=@)\S+. When extracting structured API fields from logs, you can validate extracted JSON payloads with the JSON formatter right after verifying your pattern.

Alternating highlights and the 1,000-match cap

Inside Test text, consecutive matches alternate between two highlight shades so adjacent hits remain visually distinct. When a zero-length assertion such as \b or a lookahead matches at a boundary, a thin vertical bar marks the exact offset instead of a shaded span.

To prevent browser memory spikes on huge files, the worker caps collection at 1,000 matches (displaying 1000+ matches) and renders the first 200 entries in the Matches list. Every match displays its exact character index (at <index>) so you can locate hits quickly in long multi-line files.

Why does a Web Worker stop runaway patterns after one second?

Poorly structured quantifiers can trigger exponential backtracking that freezes a single-threaded browser tab for minutes. Running every evaluation inside an isolated Web Worker lets a 1,000 ms (1 second) watchdog terminate stalled runs cleanly and keep the page responsive.

Spotting catastrophic backtracking before deployment

Nested repeats such as (a+)+ or (a|aa)+ force backtracking NFA engines to test exponentially many paths when a string almost matches and then fails at the end. The OWASP ReDoS Prevention Guide documents how a 30-character input can lock up production Node.js servers.

Testing untrusted or complex patterns here reveals performance cliffs before they ship. When validating CSS or design tokens with hex patterns like #([0-9a-fA-F]{6}|[0-9a-fA-F]{3}), you can verify matched HEX and RGB values in the color converter.

Watchdog termination and automatic worker recovery

When a pattern exceeds 1,000 ms, the watchdog calls worker.terminate(), clears the stalled thread, and shows a clear hint to simplify nested repeats. As soon as you edit Pattern or Test text, a fresh worker spawns automatically with zero page reload required.

Invalid syntax such as an unclosed character class or trailing backslash reports the exact JavaScript RegExp error inline below the flag pills without clearing your Test text or Replacement template.

Live Replace previews with $1, $&, and named references

Checking Replace opens the Replacement input and renders the transformed text live in Result with a one-click Copy button. Unlike external scripts, you can test $1, $&, and $<name> substitutions interactively before pasting them into your codebase.

Running substitutions off the main thread relies on the MDN Web Workers API Reference, ensuring large find-and-replace previews never lag while typing. Use the table below as a quick reference for JavaScript replacement tokens and flag behavior.

Token or flag Syntax Meaning in JavaScript RegExp Practical example
Whole match $& Inserts the entire matched substring [$&] wraps hits in brackets
Numbered group $1, $2 Inserts capture group 1 or 2 $1 at $2 reformats email parts
Named group $<name> Inserts (?<name>...) capture $<year>-$<month> reorders dates
Literal dollar $$ Inserts a single $ character $$$1 prefixes a price
Global flag g Replaces every match instead of first Required for full-file rewrites
Multiline flag m Applies ^ and $ per line Strips leading prefixes on each line

Tip: After running a bulk find-and-replace on configuration or log files, paste the original and updated versions into Text diff to verify every changed line side by side.

Questions

Which regex flavor does this tester use?

It runs JavaScript's built-in RegExp engine from your browser, matching Node.js and modern web runtimes. You get full support for named capture groups, lookbehind assertions, Unicode property escapes, and sticky matching.

What happens if a pattern hangs or backtracks?

Matching runs inside a background Web Worker with a 1,000 ms (1 second) watchdog timer. If catastrophic backtracking stalls execution, the worker is terminated and replaced automatically so your browser tab stays responsive.

How do I reference named capture groups in Replace?

Check Replace and use $<groupName> inside the Replacement input, where groupName matches (?<groupName>...) in your pattern. You can also use $1 or $2 for numbered groups and $& for the entire matched substring.

Why does the Matches panel stop at 200 items when more matches exist?

The worker collects up to 1,000 matches (showing a + suffix on the counter when capped) so dense logs stay fast. The Matches sidebar renders the first 200 entries to keep DOM scrolling smooth while Test text highlights every collected match.

Can I test zero-length matches like lookahead assertions?

Yes. When a pattern matches zero characters, such as a word boundary or positive lookahead, the highlight layer draws a crisp vertical bar at the exact character index and lists (empty) in the Matches panel.

How do I match Unicode emoji and international letters?

Toggle the u (Unicode) flag pill below Pattern so quantifiers treat multi-byte emoji as single code points and enable property escapes like \p{L} for international letters. Even without u enabled, the highlighter avoids splitting UTF-16 surrogate pairs.

What is the difference between sticky y and global g flags?

The g flag scans forward across the entire input to find every match anywhere in Test text. The y (sticky) flag anchors matching strictly at lastIndex, so matching stops immediately if the next character fails the pattern.

Updated