I am using regex to strip quotes from a String value. These String values can contain escaped quotes but also escaped backslash characters.
I do not want to remove escaped quotes, only non-escaped quotes. However, the cases where escaped backslash characters are preceding a non-escaped quote is causing difficulty.
I want results like the following:
"value" -> value
'value' -> value
"\"value\"" -> \"value\" <-- contains escaped quotes
"value\" -> value\"
"value\\" -> value\\ <-- contains escaped backslash before non-escaped quote
"""val"ue\\\""" -> value\\\"
The following regex almost works for me, except that it is also stripping backslashes when there is an even number of them before a quote, when I only want to escape double and single quote characters.
(?<!\\\\)(?:\\\\{2})*[\"']