My string delimiter is ;. Delimiter is escaped in the string as \;. E.g.,
irb(main):018:0> s = "a;b;;d\\;e"
=> "a;b;;d\\;e"
irb(main):019:0> s.split(';')
=> ["a", "b", "", "d\\", "e"]
Could someone suggest me regex so the output of split would be ["a", "b", "", "d\\;e"]? I’m using Ruby 1.8.7
1.8.7 doesn’t have negative lookbehind without Oniguruma (which may be compiled in).
1.9.3; yay:
1.8.7 with Oniguruma doesn’t offer a trivial split, but you can get match offsets and pull apart the substrings that way. I assume there’s a better way to do this I’m not remembering:
Other options include:
;and post-processing the results looking for trailing\\, or