Worst Case Analysis for Regular Expressions
Regexbuddy's debugger shows how many steps engine would take to conclude match or not on a given sample. More information on catastrophic backtracking and debugging regular expressions.
PS: It is not free but they offer a 3-month money-back guarantee.
Note that it depends on the engine. While regex theory is based on straight automata theory, most of the engines are not strict translations of those theories. For this reason, for instance, some engines incur in exponential time while strict NFA processing would not.
You might get what you're looking for something like using re.compile
with re.DEBUG
. See this excellent answer from the Python Hidden Features Community wiki for an extensive explanation.