I am currently trying to split a string on the pipe delimiter:
999|150|222|(123|145)|456|12,260|(10|10000)
The catch is I don't want to split on |
inside of parentheses, I only want to split on this character outside of parentheses.
This is just splitting on every |
character, yielding the results 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 am looking to get the following results keeping everything inside of parentheses:
[[1]]
[1] "999" "150" "222" "(123|145)" "456"
[6] "12,260" "(10|10000)"
Any help appreciated.