On 02.06.2008, at 17:27, Ng Stanley wrote:
I would like to replace "AAAAA BBBBB" by "AAAAA-BBBBB" and "AAAAAA
(DD)" by
"AAAAAA" using a single gsub. Is that possible besides using two
gsub ?
Could you be a bit more precisely?
If you are dealing with two fix strings then you can write
ifelse(theString == "AAAAA BBBBB", "AAAAA-BBBBB", "AAAAAA")
if not, one could find a regexp to solve that problem, but one could
also use gsub in a cascade:
gsub('regexp1', 'replace1', gsub('regexp2', 'replace2', theString) )
etc.
--Hans
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.