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.

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to