What's the RegEx to make sure that delimiters are escaped?
- by Kuyenda
I'm looking for a regular expression that will check whether or not delimiters in a string are escaped with a backward slash.
The delimiters I am concerned about are comma (\,), colon (\:), semicolon (\;) and of course the backward slash itself has to be escaped (\).
For example, the string "test" should return a match because there are no delimiters in it, and no escaping is necessary. The string "te\;st" would return a match because the semicolon delimiter is escaped. "te;st" and "t\;s:t" would both fail because the both contain at least one delimiter that is not escaped.
I know that I need a conditional and a positive look behind, and this is what I have so far, but it is not giving me the expected answer.
^(?<delimiter>[:;,\\])?(?(delimiter)\(?<=(?:\\\\)*\\)k<delimiter>|.)$
Any suggestions on how I can make this work?
Thanks.