http://qs321.pair.com?node_id=11109587

Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings wise and ancient monks of the order of Perl

When a regex is run it may take a few steps to match a string, it may back track a little, or it may enter the world of catastrophic backtracking.

We have an application where users can create regex patterns to run against a logfile Sometimes the user created patterns stray into the zone of catastrophe, and the servers can spend more CPU trying to match patterns in the logfile than doing real work.

I would like a way to pre-validate user's regex against a few hundred sample lines, and ensure that they never enter the world of ridiculous step count. Is there a way to get the regex engine to tell me how many steps it took?

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!