[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Hanging regex
On Sat, Nov 17, 2012 at 9:05 PM, David Carlisle <davidc@xxxxxxxxx> wrote: > On 17/11/2012 18:04, Ihe Onwuka wrote: >> >> David's solution set me on the right track but was too permissive. > > > Oh, I made it match exactly the same things as the original (or at least > that was the intention) but without the exponential backtracking. > Your new version requires a digit as you have a \d+ which was not in the > original. > In that case let me first rephrase by saying that it was my regex that was too permissive and not your transliteration. You'll have to excuse me, it's been 10 years since I forgot my copy of Friedl at a tube station and I haven't written a regex in anger since. I'm amazed that I recall as much as I do but that recollection certainly doesn't extend to parsing regex performance. I fixed this (and learned a valuable heuristic to boot) from being made to realise that since my regex contained a repeatable component that matched the empty string it must be wrong since that was not my intent. , I had no idea that the difference manifests in the new regex as requiring a digit (actually it requires a digit or a solitary minus sign). The mental process I went through to get there was to apply the heuristic I had just learned - cojoined with my favourite other heuristic - get it right and the performance will take care of itself (you'll either not notice a need to make it faster or it will become very apparent that you need to). Another valuable lesson has been learned. It's time to replace my lost copy of Friedl.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|