What is the best way to split a string into an unescaped character? For instance. split this (raw) line
`example string\! it is!split in two parts`
on '!', so it creates this array:
["example string! it is", "split in two parts"]
std.regex.split seems almost correct. However, there is a problem, this code matches the correct separator character, but also uses the last character on the left side.
auto text = `example string\! it is!split in two parts`; return text.split(regex(`[^\\]!`)).map!`a.replace("\\!", "!")`.array;
A full match of regular expressions is removed during the split, so this array is the result of:
["example string! it i", "split in two parts"]
What is the best way to get to the first array without iterating the string itself?
source share