[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TPJ One-Liner #39



On Sat, Jul 10, 1999 at 01:37:02AM +0100, Adam Rice wrote:
> Quoting Peter Haworth (pmh@edison.ioppublishing.com):
> > OK then. Try using POSIX character classes once they're available:
> >   /\b[:upper:]\w*/
> 
> > ...
> 
> > "Wow, that's loathsome.
> 
> I couldn't agree more.
> 
> >                          I really like it."
> 
> But here I must disagree. Must we pollute Perl's wondrous regular
> expressions with POSIX nastiness? Is it not enough of a transgression of
> truth and justice that POSIX standardised a broken and wrongheaded regular
> expression syntax, without compounding the error by making Perl sup of this
> poison?

What is wrong with the POSIX character class syntax?  It provides a clear
name for each class, and does not conflict with regular character classes.


> I agree that Perl should have a localisation-independant means to match
> upper case characters, but it should be wondrously beautiful, in keeping
> with Perl's spirit. Making \u and \l be magical inside character classes
> should be sufficient, so the above example would be
> 
> /\b[\u]\w*/
> 
> which has the added benefit of being shorter than the original. It would
> also work inside tr///, where the POSIX horror dare not venture.

Backwards compatibility.  Regular expressions are a double-quotish
contexts, so \u already has meaning there, even within a character class.

In addition, POSIX provides more than just [:upper:] and [:lower:]
character classes.  We can't implement all of them using \ escapes; we will
very quickly run out of characters to escape.


> To avoid making another post, I would just like to point at the person who
> regressed back to the original Perl Journal code and say "HA HA!".

I would like to point out that the problem with the original TPJ code was
the regex, and the person who "regressed back" did use an improved regex,
so I'm not sure what you're laughing about.

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe