M
Michael Schuerig
I'm trying to come up with an *elegant* way to split a string into an
array at a separator with the additional feature that the separators
can be escaped. It should work like this
"Hello\, World,Hi".split_escapable(',' '\')
# => ["Hello, World", "Hi"]
Through a number of permutations with regexps, scan and the rest of the
family, I was unable to find a solution. I could parse the given string
myself, going though it character by character, but I'd prefer a less
pedestrian approach.
Michael
array at a separator with the additional feature that the separators
can be escaped. It should work like this
"Hello\, World,Hi".split_escapable(',' '\')
# => ["Hello, World", "Hi"]
Through a number of permutations with regexps, scan and the rest of the
family, I was unable to find a solution. I could parse the given string
myself, going though it character by character, but I'd prefer a less
pedestrian approach.
Michael