From ggrothendieck at myway.com  Fri Nov  5 17:26:47 2004
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Fri Nov  5 17:26:54 2004
Subject: [Rd] wishlist: \& or \0 in sub/gsub
Message-ID: <loom.20041105T172526-988@post.gmane.org>


This is a wish list item.

It would be nice if one could use \0 or \& in sub and 
gsub as in vi:

	gsub("an", ":\\&:", "banana")

One can, of course, write the following right now:

	gsub("(an)", ":\\1:", "banana")

But often the this is within a function and the "an"
is passed which means that one must use paste to
construct the "(an)" argument.  

Thus:

	f <- function(x,y) { 
		x <- paste("(", x, ")", sep = "")
		gsub(x, ":\\1:", y)
	}

simplifies to:

	f <- function(x,y) gsub(x, ":\\&:", y)

I have seen at least one post on r-help where this could have been
used to good effect to simplify the answer.

It would be neater if \& or \0 could be used instead.
Obviously this is not a huge issue but it would be nice.


[Rd] wishlist: \& or \0 in sub/gsub
Gabor Grothendieck