I'm looking for a regular expression that matches strings for a syntax highlighter used in a code editor. I've found
(")(?:(?!\1|\\).|\\.)*\1
from here regex-grabbing-values-between-quotation-marks (I've changed the beginning since I only need double quotes, no single quotes)
The above regular expression correctly matches the following example having escaped double quotes and escaped backslashes
"this is \" just a test\\"
Most code editors however also highlight open ended strings such as the following example
"this must \" match\\" this text must not be matched "this text must be matched as well
Is it possible to alter the above regular expression to also match the open ended string? Another possibility would be a second regular expression that just matches the open ended string such as
"[^"]*$ but match only if preceded by an even count of non-escaped quotes