a regex engine built from scratch · zero dependencies

regexlab

Type a regular expression and a string. regexlab compiles the pattern to a state machine (a Thompson NFA) and matches by stepping every possible state at once — so it runs in linear time and never backtracks. Watch it run below.

character / class edge ε (empty) move ● active now ◎ accept state

Patterns like (a+)+c famously make backtracking engines hang for minutes on a long non-matching string — a "ReDoS". Because regexlab keeps the set of all possible states instead of trying paths one by one, it answers the same pattern in a millisecond. The CLI (regexlab test / match / grep) runs the same engine. Source & install on GitHub.