[tpm] New Regex question - partially solved

Liam R E Quin liam at holoweb.net
Sun Oct 28 11:22:20 PDT 2012


On Sun, 2012-10-28 at 12:02 -0400, Uri Guttman wrote:
> On 10/28/2012 06:45 AM, Rob Janes wrote:
[...]
> please read the docs. you are greatly mistaken about \1 and $1.

You're talking past one another, because Rob missed the word
"replacement" in the original note. I think Rob thought it was a
question about back-references, which indeed use \1 (or the extended
newer syntax).

\1 does work in the replacement, and always has, because that's the
syntax ed used (and hence sed, ex, vi, and others).

But it's not a good idea, and these days $1 is preferred, I think we
also all agree on that. I a not sure when $ was introduced for the
replacement string, I think in Perl 4.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Co-author: 5th edition of "Beginning XML", Wrox, July 2012



More information about the toronto-pm mailing list