Regex Simplifier is an online regex minimizer that converts a pattern into automata, performs formal DFA minimization, and returns a cleaner equivalent expression for multiple regex engines.
If you are searching for a regex optimizer, regex minimizer, or regex simplifier online, this tool is built for correctness-driven simplification instead of heuristic string rewriting.
Algorithmic Pipeline
- Parsing: Build an AST for a regular subset of regex syntax.
- Thompson Construction: Convert AST to an epsilon-NFA.
- Determinization: Use subset construction to obtain a DFA.
- Minimization: Apply Hopcroft minimization to compute a minimal DFA.
- Regex Reconstruction: Use state elimination on a GNFA-style form to produce a simplified regex.
The resulting language is preserved for the supported regular subset, and the minimized DFA provides a canonical target for equivalence at the automaton level.
Dialect Output
The tool renders output for common regex dialects:
- JavaScript
- PCRE
- RE2
- sed (
-Emode) - tiny-regex-c
A shared internal form is translated to each dialect so you can copy the target representation directly.
Regex Feature Matrix by Dialect
| Feature | JavaScript | PCRE | RE2 | sed -E | tiny-regex-c |
|---|---|---|---|---|---|
| Literals / Character Classes | Yes | Yes | Yes | Yes | Yes (subset) |
Alternation | | Yes | Yes | Yes | Yes | Yes |
Quantifiers * + ? {m,n} | Yes | Yes | Yes | Mostly | Limited |
Non-capturing Group (?:...) | Yes | Yes | Yes | No | No |
| Lookaround | Partial | Yes | No | No | No |
| Backreferences | Yes | Yes | No | No | No |
The minimizer intentionally rejects non-regular extensions such as backreferences and lookarounds, because they are outside classical DFA minimization theory.
Automaton Modal View
The tool can display the minimized DFA in a modal window. You get both a graph-style visualization and a transition table, which makes it easier to verify language-equivalence and understand state merges after minimization.
Theory
Thompson Construction (Regex to epsilon-NFA)
Each regex operator is converted into a small epsilon-NFA fragment and then composed recursively. Concatenation chains fragments, alternation adds branching epsilon edges, and Kleene star introduces loop and bypass edges.
$$ r \Rightarrow N_r = (Q, \Sigma, \delta, q_0, F) $$For concatenation $rs$, the accept state of $N_r$ connects by epsilon transition to the start state of $N_s$.
Subset Construction (NFA to DFA)
Each DFA state corresponds to a set of NFA states. Transitioning on symbol $a$ means applying move and then epsilon-closure:
$$ \delta_D(S, a) = \varepsilon\text{-closure}\left(\bigcup_{q \in S} \delta_N(q, a)\right) $$This produces a deterministic automaton recognizing the same language as the NFA.
Hopcroft Minimization (DFA Minimization)
Hopcroft starts from the partition of accepting and non-accepting states and repeatedly refines blocks using distinguishing transitions until no split is possible.
$$ P_0 = \{F,\ Q \setminus F\} $$The final partition defines the minimal DFA (up to isomorphism), which is optimal in number of states.
Supported Feature Scope
For algorithmic correctness, minimization is restricted to regular constructs such as concatenation, alternation, quantifiers, groups, character classes, and escaped character classes.
Non-regular extensions (for example backreferences and lookarounds) are intentionally rejected, because they cannot be minimized with classical DFA methods.
Why This Is Useful
- Reduce regex complexity while preserving language semantics in the supported subset
- Compare regex behavior across multiple engine dialects
- Inspect NFA/DFA state counts for optimization and debugging
- Create maintainable regex patterns for production systems