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.
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Archive generated by hypermail 2.2.0, at Mon 02 Jun 2008 - 20:32:15 GMT.
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.
list of date sections of archive