I am looking for an efficient and correct way to split a string against an escapable delimiter. Let's say the delimiter is @ and the escape char #. The escape char is used to cancel any special effect of the following character (including the escape itself). Using this encoding, "one@two@three" would be split into the three strings "one", "two" and "three" ; "## is a hash and #@ is an arobace" would be split into a single string identical to the input ; "#@##@###@####@#####@" would be split into "#@##", "###@####", "#####@".
In other terms @ is a real delimiter only when preceded by zero or an even number of #.
I am currently working in two steps, first splitting on @ irrespective of any preceding escapes, and then joining back consecutive strings as needed. There is certainly a better way.
Any taker ? TIA.
In reply to Splitting on escapable delimiter by Daryn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |