Re: is \1 vs $1 a necessary distinction?

[email protected] (Dave Storrs) Wed, 27 Sep 2000 09:45:50 -0700 (PDT)
Newsgroups perl.perl6.language.regex
Message-ID <Pine.BSF.4.10.10009270942560.89122-100000@megazone23.bigpanda.com>

On 27 Sep 2000, Piers Cawley wrote:

> > 	Do we *want* to maintain \1?  Why have two notations to do the
> 
> I'm kind of curious about what happens when you want to do, say:
> 
>   if (m/(\S+)/) {
>      $reg = qr{<(em|i|b)>($1)</\1>};
>   }
> 
> where the $1 in the regex quote is refering to $1 from the previous
> regex match.

	Well, how about this:

      $reg = qr{<(em|i|b)>(${P1})</\1>};
NOTE:                      ^^^^^	

	If you assume that $1 and ${1} are equivalent (which makes it
possible to have as many backrefs as you want), then you could say that,
if the first character after the { is a P, it means "in the previous regex
match."

				Dave