[R] strsplit and regexp

Patrick Hausmann Patrick.Hausmann at uni-bremen.de
Sat Aug 30 18:51:39 CEST 2008


Dear list,

I am trying to split a string using regexp:

x <- "2 Value 34 a-c 45 t"
strsplit(x, "[0-9]")

[[1]]
[1] ""  " Value "  ""  " a-c "  ""  " t"

But I don't want to lose the digits (pattern), the result
should be:

[[1]]
[1] "2" " Value "  "34"  " a-c "  "45" " t"

Thanks for any tipp
Patrick



More information about the R-help mailing list