I am currently trying to split a line on a channel separator:
999|150|222|(123|145)|456|12,260|(10|10000)
Trap: I do not want to break into |inside parentheses, I only want to break this character outside of parentheses.
This is just a split into each character |, which gives results that I don't want:
x <- '999|150|222|(123|145)|456|12,260|(10|10000)'
m <- strsplit(x, '\\|')
[[1]]
[1] "999" "150" "222" "(123" "145)" "456" "12,260" "(10"
[9] "10000)"
I want to get the following results, keeping everything inside parentheses:
[[1]]
[1] "999" "150" "222" "(123|145)" "456"
[6] "12,260" "(10|10000)"
Any help was appreciated.
source
share