Regular Expression Calculator
Match found
yes
Regular Expression Tester
First match
555-0199
Match starts at index
5
Match ends before index
13
Gave up (budget exhausted)
no
Simulation steps used
68
Compiled instruction count
9
Worked out from Ken Thompson, "Programming Techniques: Regular expression search algorithm", Communications of the ACM 11(6), 1968 and 1 other source.
This tester is deliberately not JavaScript-compatible on two points: it matches leftmost-longest rather than leftmost-first, and it refuses backreferences and lookaround outright. A pattern that works here may behave differently in a backtracking engine, and one that hangs a backtracking engine will finish here.
How this is worked out
2 steps
- Compiled "\d{3}-\d{4}" to 9 NFA instructions.
- Leftmost-longest match at [5, 13): "555-0199" in 68 steps.
Results are general information, not financial, tax, legal, medical or engineering advice.