[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Hanging regex


Subject: Re: [xsl] Hanging regex
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Sun, 18 Nov 2012 03:45:15 +0000

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.


Current Thread