Here's the string
15 3 23 11 0 51.0000000 0 18G 5G 7G 9G10G13G16G19G20G27G28G30R 2
I need to split it by "G" and "R" to get
[1] " 15 3 23 11 0 18.0000000 0 18 "G 5" "G 7" "G 9" "G10" "G13" .... "R 2"
I'm trying to use lookahead and lookbehind.
Lookbehind ss.tl.pattern="(?<=G|R[ 0-9]{2})"
split.tl=strsplit(time.lines,ss.tl.pattern,perl=TRUE)
works reasonably:
[[1]]
[1] " 15 3 23 11 0 18.0000000 0 18G 5" "G 7"
[3] "G 9" "G10"
[5] "G13" "G16"
[7] "G19" "G20"
[9] "G27" "G28"
[11] "G30" "R 2"
everything except first sep as expected
If I try lookahead for same pattern ss.tl.pattern="(?=G|R[ 0-9]{2})"
it goes wrong:
[[3]]
[1] " 15 3 23 11 0 20.0000000 0 18" "G"
[3] " 5" "G"
[5] " 7" "G"
[7] " 9" "G"
[9] "10" "G"
[11] "13" "G"
[13] "16" "G"
[15] "19" "G"
[17] "20" "G"
[19] "27" "G"
[21] "28" "G"
[23] "30" "R"
[25] "2"
I can't figure out why it splits both before and after "G" or "R".