DataToolsLab
Regex & Pattern Tools

Regex Diff

Compare two regex patterns side-by-side, highlighting token-level differences.

Loading tool…

What is Regex Diff?

A diff tool specialized for regex patterns. Unlike a generic text diff, this one tokenizes each regex and aligns them structurally, so a changed quantifier on the same group shows as a single modification rather than a garbled text diff.

How it works

We tokenize both regexes, compute the longest common subsequence of tokens, then render a side-by-side view with additions, deletions, and unchanged tokens color-coded.

  1. Enter your input. Type or paste your input into the field above — the tool responds instantly.
  2. Review the result. Output updates live as you type. Everything runs entirely in your browser.
  3. Copy or download. Use the Copy button to grab the result, or Download to save it as a file.

Examples

Comparing two patterns

Paste two regexes and see where they differ textually — then test sample strings to understand behavioral differences.

Common mistakes

Text diff isn't equivalence

Different text can match identically, and similar text can match differently — semantic equivalence is only approximated.

Frequently asked questions

How is this different from a plain text diff?

Both patterns are tokenized first — groups, character classes, quantifiers, literals and anchors — and those token sequences are aligned. A changed quantifier on the same group therefore shows as a single modification instead of a garbled character-by-character diff.

Does an empty diff mean the two patterns behave the same?

No. The diff compares the pattern source, not what it matches, so equivalent patterns such as \d and [0-9] still show as different. Use the regex tester or optimizer when you care about behaviour rather than spelling.

What do the colours mean?

Unchanged tokens are grey, tokens present only in the right-hand pattern are green, and tokens only in the left-hand pattern are red.

Online