[R] Do grep() and strsplit() use different regex engines?
Bert Gunter
bgunter.4567 at gmail.com
Sat Jul 11 16:47:22 CEST 2015
I noticed the following:
> strsplit("red green","\\b")
[[1]]
[1] "r" "e" "d" " " "g" "r" "e" "e" "n"
> strsplit("red green","\\W")
[[1]]
[1] "red" "green"
I would have thought that "\\b" should give what "\\W" did. Note that:
> grep("\\bred\\b","red green")
[1] 1
## as expected
Does strsplit use a different regex engine than grep()? Or more
likely, what am I misunderstanding?
Thanks.
Bert
Bert Gunter
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
-- Clifford Stoll
More information about the R-help
mailing list