Regular Expression Calculator
Regular Expression Tester works out Match found and First match from Regular expression, Text to search and Work budget (simulation steps). The default figures on this page give match found of yes; change any entry and the result, the working and the sources update together.
Your figures
Updates as you typeHow 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.
Its 3 worked examples are re-run on every release, last on 15 September 2026. What changed
Sources and references
2 sources
What the Regular Expression Tester calculates
Tests a regular expression against a piece of text with a linear-time engine that cannot hang: it simulates all match paths at once instead of backtracking, so hostile patterns like (a+)+b finish in milliseconds. Matching is leftmost-longest, which can pick a longer match than JavaScript would. Backreferences and lookaround are refused rather than faked.
How to use this Regular Expression Tester
Enter Regular expression, Text to search and Work budget (simulation steps). Match found updates as you type, and “Use a worked example” loads checked figures you can adjust. Change one figure at a time to see what drives the result.
How the result is worked out
Open “How this is worked out” beside the result for the step-by-step calculation behind Match found, First match and Match starts at index.
The method follows Ken Thompson, "Programming Techniques: Regular expression search algorithm", Communications of the ACM 11(6), 1968 and Russ Cox, "Regular Expression Matching Can Be Simple And Fast".
A phone-shaped pattern finds its span example
With Regular expression: \d{3}-\d{4}, Text to search: call 555-0199 today, the calculator returns Match found: yes, First match: 555-0199, Match starts at index: 5. This example is checked against an independent source in the test suite.
What you can compare
Change one input at a time to see how it affects Match found, First match and Match starts at index. The inputs you can vary are Regular expression, Text to search and Work budget (simulation steps).
Understanding Match found, First match and Match starts at index
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.
Results are general information, not financial, tax, legal, medical or engineering advice. Check any decision that matters with a qualified professional.
See something wrong? Report a problem with this calculator
Frequently asked questions
How to test a regular expression?
Tests a regular expression against a piece of text with a linear-time engine that cannot hang: it simulates all match paths at once instead of backtracking, so hostile patterns like (a+)+b finish in milliseconds. Open “How this is worked out” beside the result to see each step for your own figures.
What is the best online RegEx tester?
On the figures this page opens with, the match found is yes. No single number fits everyone: it follows Regular expression, Text to search and Work budget (simulation steps), so enter your own above and the answer updates as you type.
What are the benefits of using a regular expression tester?
It needs Regular expression, Text to search and Work budget (simulation steps). Nothing else is required, and the figures stay in your browser.
What information do I need for the Regular Expression Tester?
You need Regular expression, Text to search and Work budget (simulation steps). The page opens with default figures that give match found of yes, so you can see the scale before entering your own.
What does this Regular Expression Tester show?
It shows Match found, First match, Match starts at index, Match ends before index, Gave up (budget exhausted), Simulation steps used and Compiled instruction count, with the working and any warnings for your entries.
Can I check how the Regular Expression Tester result was calculated?
Yes. The “How this is worked out” section shows the calculation steps, and the sources section identifies the references used for the method.
