Re: is \1 vs $1 a necessary distinction?
[email protected] ((Randal L. Schwartz)) 27 Sep 2000 09:40:27 -0700
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Jonathan" == Jonathan Scott Duff <[email protected]> writes: Jonathan> On Wed, Sep 27, 2000 at 08:15:53AM -0700, Dave Storrs 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)? Jonathan> \1 can be used on the LHS of a s/// whereas $1 there probably won't do Jonathan> what you expect. Also, \1, \2, \3 only takes you as far as \9 ;-) Wrong. If you have more than 10 parens visible so far, \10 works just fine. Jonathan> If $1 could be made to work properly on the LHS of s///, I'd vote for Jonathan> that being The Way. It can't ever. It means $1 from the previous match. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!