Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Request for Regular Expression Feature -why not{?foo}

28 views
Skip to first unread message

Michael J. Feuell

unread,
Jun 14, 1994, 6:02:40 AM6/14/94
to
mer...@ora.com writes: [edited for space]
>Well, then, if you'd let me design out loud here, what about simply:
>
> (?foo) - a bracketing () that *doesn't* act like parens!
>
> "fred barney betty wilma" =~ /(fred) (?barney|dino) (betty) (wilma)/;
> print "$1 $2 $3"
> we get "fred betty wilma".
>
>Cool, no?

but, why have even the slightest doubt? why not {?foo|bar}, or even {foo|bar}
and save parens for just one purpose. Surely the following is clearer:

"fred barney betty wilma" =~ /(fred) {barney|dino} (betty) (wilma)/;

Stephen P. Potter

unread,
Jun 14, 1994, 9:30:46 AM6/14/94
to

How would it handle this:

"fred5 wilma2 barney11 betty12" =~ /(fred)5 (wilma){2|10} (barney)11 {betty|alex}{5|12}/;

Steve
--
University of Florida, Department of Computer and Information Sciences
email: spp@{cis.}ufl.edu smail: Stephen P Potter, E309A CSE, UF Campus
Click here for the <a href="http://www.cis.ufl.edu/perl">Perl WWW Page</a>
I BOYCOTT ANY COMPANY THAT USES MASS INTERNET ADVERTISING

Larry Wall

unread,
Jun 15, 1994, 3:40:39 AM6/15/94
to
In article <2tjv80...@twain.ucs.umass.edu> e...@twain.ucs.umass.edu (Michael J. Feuell) writes:
: mer...@ora.com writes: [edited for space]

: >Well, then, if you'd let me design out loud here, what about simply:
: >
: > (?foo) - a bracketing () that *doesn't* act like parens!
: >
: > "fred barney betty wilma" =~ /(fred) (?barney|dino) (betty) (wilma)/;
: > print "$1 $2 $3"
: > we get "fred betty wilma".
: >
: >Cool, no?
:
: but, why have even the slightest doubt?

Every now and then, paranoia is a survival characteristic.

: why not {?foo|bar}, or even {foo|bar}


: and save parens for just one purpose. Surely the following is clearer:
:
: "fred barney betty wilma" =~ /(fred) {barney|dino} (betty) (wilma)/;

Unfortunately, unbackslashed curlies are currently be interpreted
literally if they don't contain a sequence of digits (and maybe a
comma). Doubtless many people have written regular expressions to take
advantage of this. Suddenly forcing them to be metacharacters will
break things. Not to mention the fact that there's ambiguity. Is
{12345}{12345} a sequence of 12345 12345's? Does {?foo}* mean 0 or
more foos, or does it match an optional left curlie followed by foo
followed by 0 or more right curlies? It currently has the latter
meaning.

On top of which, curlies already have 5 or 6 overloaded meanings in
Perl 5. I hesitate to add yet another one. Just in terms of visual
distinction, I think <> would stand out a lot more, unless you're
matching HTML or something.

The reason we're talking about (?foo) is that it's currently illegal
to quantify a left parenthesis, so it wouldn't break anything to give
this syntax a meaning. The same cannot be said of curlies, or angle
brackets for that matter.

Anyway, there's plenty of room for doubt. It might seem easy enough,
but computer language design is just like a stroll in the park.

Jurassic Park, that is.

Larry

Randal L. Schwartz

unread,
Jun 15, 1994, 10:05:13 AM6/15/94
to
>>>>> "Michael" == Michael J Feuell <e...@twain.ucs.umass.edu> writes:

Michael> but, why have even the slightest doubt? why not {?foo|bar}, or even {foo|bar}
Michael> and save parens for just one purpose. Surely the following is clearer:

Michael> "fred barney betty wilma" =~ /(fred) {barney|dino} (betty) (wilma)/;

That's not upward compatible with:

"fred barney" =~ /(fred){1} (barney)/;

Note the difference between that and:

"fred1 barney" =~ /(fred)(?1) (barney)/; # illegal, proposed syntax

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
# legal fund: $945 collected, $9835 spent; email @FUND in body for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <mer...@ora.com> Snail/FAX: (Call) aka: <mer...@teleport.com>
Phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"

0 new messages