In a message dated Thu, 29 Aug 2002, Janek Schleicher writes:

> Aaron Sherman wrote at Wed, 28 Aug 2002 00:34:15 +0200:
>
> >     $stuff = (defined($1)?$1:$2) if /^\s*(?:"(.*?)"|(\S+))/;
>
> It gives me the idea of a missing feature:
>
> What really should be expressed is:
>
> my ($stuff) = /^\s*("°.*?"°|\S+)/;
>
> where the ° character would mean,
> "Don't capture the previous element".

Hmm.  One thing that has always bothered me about regexes is capturing
parentheses in alternations.  It seems to me that:

my ($stuff) = /^\s* [ "(.*?)" | (\S+) ]/;

should DWIM somehow, since it's impossible that both parens will capture.
So when the same number of capturing parens appear in each of an
alternation, they should factor out to being a single return value.

Is this possible in the general case?

Trey

Reply via email to