in reply to Re: Question on Regex
in thread Question on Regex
Thanks Athanasius. I got what I was looking. Thanks a lot. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question on Regex
by karlgoethebier (Abbot) on Nov 18, 2012 at 16:41 UTC | |
FYI:
Regards, Karl «The Crux of the Biscuit is the Apostrophe» | [reply] [d/l] |
by Athanasius (Archbishop) on Nov 19, 2012 at 03:39 UTC | |
Which shows that sub athanasius is up to 5 times faster than sub karlgoethebier. Even easier to see when supplying a positive COUNT value to timethese:
Output:
Not really surprising, since regexen with quantifiers can be expensive: Avoid regular expressions with many quantifiers.... Such patterns can result in exponentially slow backtracking behavior unless the quantified subpatterns match on their first “pass”. So, what happens if we limit the backtracking?
Result:
The regex is now significantly faster than split-with-subscript. Interesting! Athanasius <°(((>< contra mundum | [reply] [d/l] [select] |
by karlgoethebier (Abbot) on Nov 19, 2012 at 14:15 UTC | |
Thats's nice! It's not a good habit to be too greedy. Regards, Karl «The Crux of the Biscuit is the Apostrophe» | [reply] |
by karlgoethebier (Abbot) on Nov 19, 2012 at 20:24 UTC | |
by Athanasius (Archbishop) on Nov 20, 2012 at 02:48 UTC | |
| |