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

Re: [FWP] TPJ One-Liner #39



Quoting Ronald J Kimball (rjk@linguist.dartmouth.edu):
> 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.

As with the rest of POSIX regular expression syntax, is is \(unforgivably\)
ugly.

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

This argument would carry some weight if there was any evidence that anyone
had ever used \u inside a character class. But why would they? I've already
made a start:

perl -ne 'print if /\[[^\]]*\\[ul]/' `find /usr/lib/perl5/ -name '*.p*'`

Since I don't have fast access to a CPAN mirror, I can't do an exhaustive
search.

> 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.

According to the egrep man page, there are 11. Many of which already have
equivalents in Perl notation. It makes more sense to me to extend Perl's
existing syntax to cover the rest rather than conceding an inch of ground to
POSIX's horrible syntax.

> 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.

I was laughing because of the natural humourous qualities of someone
unknowingly recreating the original code to resolve the problem of the new
code being slightly incompatible with it. And the inevitable humiliation
that comes about when someone posts to a thread without reading it in its
entirity first.

If, however, they had gone back to using the original regex, I would have
thought they were just taking the piss.

-- 
Adam Rice -- wysiwyg@glympton.airtime.co.uk -- Blackburn, Lancashire, England

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