darkmarmot
Any examples of splitting strings with escaped delimiters?
Looking to use something like String.split – but with the option to define delimiters with potential escape characters.
It appears Elixir’s Regex doesn’t support variable width look behind assertions – so I was wondering if anyone knows some sample code or libraries that might handle this?
Thanks,
Scott S.
Most Liked
OvermindDL1
So… what, like this?
iex(1)> Regex.split(~R/(?<!\\),/, "comma,separated\\,data,is,here")
["comma", "separated\\,data", "is", "here"]
Or what is it you are looking for?
OvermindDL1
If you want "comma,separated\\\\\\\\,data,is,here" to parse into ["comma", "separated\\\\\\\\", "data" ,"is" ,"here"] then you cannot do that easily with a proper regex. Something like nimble_parsec is what you want then.
(You ‘can’ do that with a normal regex but it will start getting very hairy-large and you will require a good chunk of external code from the regex to perform the final transformation, where a peg parser can do it all in one swoop.)







