Dave Storrs <[EMAIL PROTECTED]> writes:

> On Wed, 27 Sep 2000, Richard Proctor wrote:
> > > Both \1 and $1 refer to what is matched by the first set of parens in a
> > > regex.  AFAIK, the only difference between these two notation is that \1
> > > is used within the regex itself and $1 is used outside of the regex.  Is
> > > there any reason not to standardize these down to one notation (i.e.,
> > > eliminate one or the other)?
> > 
> > I think this is fixable.  
> 
>       The way you phrase that makes it sound that other people perceive
> this as a problem as well, which gives me all sorts of warm fuzzies. :>
> 
> >The only real need for this at the moment is to
> > overcome limitations in the order of expansion of regexes.  RFCs 112, 166,
> > 276... all depend on fixing this.  
>
> [...]
> 
> >If the regex compiler gets in before the
> > expansion of the variables to make these work, it could handle $1 in all cases
> > \1 can be retained for compatibility.
> 
>       Do we *want* to maintain \1?  Why have two notations to do the
> same thing when one is clearly superior?  (\1 can only go up to \9 while
> the other could theoretically go to ${9999...}.)  Perl6 is breaking
> backwards compatibility and eliminating all deprecated features...let's
> get rid of \n as backreference notation.

I'm kind of curious about what happens when you want to do, say:

  if (m/(\S+)/) {
     $reg = qr{<(em|i|b)>($1)</\1>};
  }

  while (<>) {
    next unless m{$reg};
    ...
  }

where the $1 in the regex quote is refering to $1 from the previous
regex match.

-- 
Piers

Reply via email to