REGEX WORKBENCH

Test a pattern against real text, see every match and capture group, preview a replacement, and read what the pattern means in plain English.

Zero retention: your text never leaves this browser. Verify it yourself in DevTools

Loading the workbench.

About 2regex

How Can You Verify That Your Text Never Leaves This Browser?

You do not have to take our word for it. Developer tools show every request a page makes, so you can watch 2regex work and confirm that nothing is sent. Auditable trust is worth more than a badge, and the check takes under a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files, its web fonts, and one anonymous page-view request. Nothing has been typed yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Type a pattern, paste your text, and use any tab: match, replace, explain, or save.
  5. Look at the Network tab again. It is still empty. For extra proof, turn on offline mode after the page loads and the tools keep working.

Only three things can add a line to that log, and none of them carries your text. Submitting the feedback form sends the vote and comment you typed. Pasting text in a script the page has not displayed yet, such as Cyrillic or Greek, can make the browser fetch the matching font file, and that request names only the font. When a runaway pattern is stopped, the browser restarts the matching worker from a blob: address, which is a copy held in this tab's memory and does not touch the network.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint. A coding mistake could not quietly send your data elsewhere, because the browser itself would block the request.

What Is 2regex?

2regex is a free regular expression workbench that runs entirely in your web browser. A regular expression, or regex, is a compact pattern that describes text, and developers use one to validate input, extract values, and rewrite strings.

2regex shows what a pattern really does against your own text. Every match is highlighted as you type, capture groups appear in their own colors, and each token of the pattern can be read in plain English. Matching uses the native JavaScript engine in your browser, so a result here is the result your JavaScript code will get in that browser.

Why Does Zero Retention Matter for a Regex Tester?

Regex testing works best on real text, and real text often means production logs, customer records, or access tokens. Many online testers send what you paste to a server, and some offer save features that create public links. Zero retention means a tool has nothing to leak because it never receives your data.

2regex has no accounts, no pattern database, and no share links. Your text exists only in the memory of this browser tab, and it is gone when you close the tab. The only values remembered between visits are your theme and your active tab.

What Tools Are Included?

  • Matches: live highlighting with colored capture groups, a table of every match with named groups and exact spans, and a complete match count.
  • Replace: a live substitution preview using numbered references such as $1 and named references such as $<year>. Each reference is checked, so a typo is flagged before it reaches your code.
  • Explain: a token-by-token breakdown of the pattern in plain English, including nested groups, lookaround, and every flag you have turned on.
  • Code: copy the finished pattern as a JavaScript regex literal or a new RegExp call, with escaping handled for you.
  • Saved: keep patterns for the session, then export them to a JSON file and import them whenever you need them again.
  • Reference: fifteen click-to-load patterns for common jobs, plus a compact syntax list that inserts each token at your caret.

How Do You Use 2regex?

  1. Type a pattern in the Pattern field, or load one from the Reference tab.
  2. Choose flags. The most common is g, which finds every match rather than only the first.
  3. Paste your test text. Include valid cases, invalid cases, and edge cases such as empty values.
  4. Read the highlights and the capture table, and open Explain if a result surprises you.
  5. Copy the pattern as JavaScript once it behaves correctly on every case.

What Do the Regex Flags Do?

  • g, global: finds every match instead of stopping at the first.
  • i, ignore case: treats upper and lower case letters as equal.
  • m, multiline: makes ^ and $ match at each line.
  • s, dot all: lets the dot match line breaks.
  • u, unicode: reads the pattern as full Unicode code points and enables property escapes such as \p{L}.
  • v, unicode sets: adds set operations inside character classes, and replaces u.
  • y, sticky: requires each match to begin exactly where the last one ended.

What Is Catastrophic Backtracking?

Catastrophic backtracking is a failure where a regex engine tries an exploding number of ways to divide up the same text. A pattern such as (a+)+$ can take years to fail on a string of a few dozen letters, because each extra character roughly doubles the work.

2regex runs matching in a background worker and stops it after about one second, then shows a Timed out status. The page never freezes. To fix a slow pattern, remove quantifiers nested inside other quantifiers, and make each alternative start differently.

How Do Capture Groups Work?

A capture group is a part of a pattern wrapped in parentheses, and it saves the text it matched. The pattern (\d{4})-(\d{2}) captures a year and a month separately. A named group, written (?<year>\d{4}), gives that value a label your code can read.

A non-capturing group, written (?:...), groups parts without saving anything. Non-capturing groups are useful for applying a quantifier or alternation while keeping the numbering of your real captures unchanged.

What Is the Difference Between Greedy and Lazy Matching?

A greedy quantifier takes as much text as it can while still allowing the overall match to succeed. A lazy quantifier, written with a trailing question mark, takes as little as it can. Against <b>bold</b>, the greedy <.*> matches the whole string, while the lazy <.*?> matches each tag separately.

A negated character class such as <[^>]*> is often better than either choice, because it states exactly where the match must stop and avoids unnecessary backtracking.

What Are Lookahead and Lookbehind?

Lookahead and lookbehind are zero-width assertions, which check the text around a position without including it in the match. The pattern \d+(?=px) matches digits only when px follows, and (?<=\$)\d+ matches digits only when a dollar sign comes before them.

Negative forms, (?!...) and (?<!...), require that the text does not appear. Because lookaround consumes nothing, several checks can be stacked at one position, which is how password rules are usually written.

What Are the Most Common Regex Mistakes?

  • Forgetting to escape metacharacters. A literal dot must be written \..
  • Using .* where a negated class would state the boundary precisely.
  • Omitting the m flag when ^ and $ should apply to each line.
  • Omitting the u flag on text with emoji, which splits them into two halves.
  • Parsing nested HTML with a regex rather than a real parser.
  • Testing only the inputs that should match, and never the ones that should not.

How Does JavaScript Regex Differ From Other Languages?

Most core syntax is shared across languages, but the details differ. Python writes named groups as (?P<name>...), where JavaScript uses (?<name>...). Go uses the RE2 engine, which has no backreferences or lookaround and in exchange cannot backtrack catastrophically. PCRE, used by PHP, adds recursion and conditionals that JavaScript lacks.

2regex tests JavaScript behavior only, so a pattern headed for another language should be checked in that language as well.

Who Is 2regex For?

  • JavaScript and TypeScript developers writing validation and parsing code.
  • Data engineers extracting fields from logs and exports.
  • QA engineers checking assertions against real output.
  • Anyone learning regular expressions, one explained token at a time.
  • Anyone who works under a policy that forbids pasting data into third-party services.

Part of the 2suite.io privacy-first ecosystem. Working with JSON instead? 2json is the matching workbench for JSON documents.

Frequently Asked Questions

Is 2regex free?

Yes. Every tool is free, with no account, no usage limits, and no paid tier.

Are my patterns and test text uploaded to a server?

No. All matching runs in your browser, so your text never leaves this browser. Patterns and test text are not uploaded or stored, and only your theme and active tab are remembered between visits.

Does 2regex collect any analytics?

Yes, one anonymous page-view count when the page loads, before you can type anything. It records the app name, the event name, and a random ID for that browser tab. If you submit the feedback form, your vote, your comment, and your browser type are sent too. Your patterns and test text are never included.

Which regex flavor does 2regex use?

2regex uses the native JavaScript RegExp engine in your browser, so results match what your JavaScript code will do in that browser. Very new syntax depends on your browser version. Other languages, such as Python or Go, can behave differently.

What happens if my pattern takes too long?

Matching runs in a background worker that is stopped after about one second. The page stays responsive and shows a Timed out status, which usually points to catastrophic backtracking from nested quantifiers.

What are the carets in the highlighted text?

A caret marks a zero-length match, which matches a position and consumes no characters. Patterns such as a* or a lookahead on its own can produce them. They are real matches, so they are included in the count.

Can I save or share my patterns?

You can save patterns for the current session and export them to a JSON file, which you can import later. There are no share links, because a share link would require storing your data somewhere or putting it in a URL.

How many matches can 2regex show?

The match count is always complete. To keep the page responsive, the first 5,000 matches are highlighted and the first 1,000 are listed in the table, and the page tells you when that limit applies.

Was this helpful?