Re: regex of the month (decade?)

Sébastien Aperghis-Tramoni <[email protected]> Fri, 11 Jan 2008 03:32:19 +0100
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
Dan Collins wrote:

> On Jan 7, 2008 5:06 PM, Uri Guttman <[email protected]> wrote:
>
>> ^([Pp]([Oo][Ss][Tt])?[.\s]*[Oo]([Ff][Ff][Ii][Cc][Ee])?[.\s]*[Bb][Oo]
>> [Xx])|[Pp][Oo]([Bb]|[Xx]|[Dd][Rr][Aa][Ww][Ee][Rr]|[Ss][Tt][Oo][Ff] 
>> [Ff]
>> [Ii][Cc][Ee]|[ ][Bb][Xx]|[Bb][Oo][Xx])|[Pp][/][Oo]|[Bb]([Xx]|[Oo] 
>> [Xx]|
>> [Uu][Zz][Oo][Nn])|[Aa]([Pp][Aa][Rr][Tt][Aa][Dd][Oo]|[Pp][Tt][Dd][Oo])
>>
>> the challenge: itemize the stupidities. the case issue is only 1! i
>> don't want to even post the 'spec' unless asked for it. i saw this on
>> usenet today.
>
> I don't even want to know what that's supposed to do.
> First, and most obviously, that should use /i.

You can also find code like this in HTML::Template. Sam Tregar  
explained the reason in the FAQ:

     Q: Why do you use /[Tt]/ instead of /t/i? It's so ugly!

     A: Simple - the case-insensitive match switch is very
     inefficient. According to "Mastering Regular Expressions"
     from O'Reilly Press, /[Tt]/ is faster and more space
     efficient than /t/i - by as much as double against long
     strings. //i essentially does a lc() on the string and
     keeps a temporary copy in memory.

     When this changes, and it is in the 5.6 development series,
     I will gladly use //i. Believe me, I realize [Tt] is hideously
     ugly.

   » http://search.cpan.org/dist/HTML-Template/ 
Template.pm#FREQUENTLY_ASKED_QUESTIONS


-- 
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.