On 22-03-2012, at 08:23, jing tang wrote: > Hi, > > I tried to use strsplit for separating a string with || like > strsplit(string,"\\||") but it returned each single character was separated. > > For example: > > strsplit("a||bc","\\||") > > [[1]] > > [1] "a" "" "" "b" "c" > > where I want the result to be "a" and "bc". >
You should escape both \'s. strsplit("a||bc","\\|\\|") Berend ______________________________________________ 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.