What's the regex to match anything except a double quote not preceded by a backslash?

regex

Solution

No lookbehind necessary:

"(\\"|[^"])*"

So: match quotes, and inside them: either an escaped quote (`\\"`) or any character except a quote (`[^"]`), arbitrarily many times (`*`).

Problem

In other words, I have a string like: "anything, escaped double-quotes: \", yep" anything here NOT to be matched. How do I match everything inside the quotes? I'm thinking `^"((?<!\\)[^"]+)"` But my head spins, should that be a positive or a negative lookbehind? Or does it work at all? How do I match any characters except a double-quote NOT preceded by a backslash?

Original source