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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex step counting
by LanX (Saint) on Dec 03, 2019 at 13:25 UTC | |
by Random_Walk (Prior) on Dec 03, 2019 at 17:07 UTC | |
by LanX (Saint) on Dec 03, 2019 at 22:21 UTC | |
by Anonymous Monk on Dec 04, 2019 at 01:07 UTC | |
Re: regex step counting
by Fletch (Bishop) on Dec 03, 2019 at 13:56 UTC | |
Re: regex step counting (Halting problem)
by LanX (Saint) on Dec 03, 2019 at 14:29 UTC | |
by Corion (Patriarch) on Dec 03, 2019 at 14:45 UTC | |
by LanX (Saint) on Dec 03, 2019 at 14:51 UTC |