Friday, 6 September 2013

How can I write a regex that splits a string but ignores an escape sequence of the separator?

How can I write a regex that splits a string but ignores an escape
sequence of the separator?

I'm looking to use PHP's [mb_split][1] to split a string that is
colon-separated, but ignores an escaped colon (i.e. \:).
For instance:
Part A is here:Part B\: is over here:Part C\ is here:Part \\:D is here
needs to be split into:
Part A is here
Part B: is over here
Part C\ is here
Part \:D is here
I'm not really sure how to go about this. Any advice?

No comments:

Post a Comment