I am trying to build a regex which is able to match double quoted strings. Here is what I have:
regex = /\"(\\\"|[^\"])*\"/g
It works for almost all cases. But there is a case for which it does not capture the string correctly. For instance if the input is "\" it should not capture it as a double quoted string, since \" would be a the character '"'. For this purpose I tried to figure out the condition required, which it is:
- If the previous character of the closing double quote is '\' do not capture it. But honestly I don't know how to express this into the regex expression.
I would appreciate some tips and help to get this done. Thanks beforehand