The problem is the escaped quotes:
\S+=(\([^(]*(?:[^("]*"(?:[^\\"]|\\["\\])*")(\)))
https://regex101.com/r/3ytO9P/1
I changed [^"]
to (?:[^\\"]|\\["\\])
. This makes the regex look for either a regular character or an escape. By matching the escape, it doesn’t allow \"
to end the match.
Your regex has other problems though. This should work better:
\S+=(\([^("]*(?:[^("]*"(?:[^\\"]|\\["\\])*")*(\)))
https://regex101.com/r/OuDvyX/1
It changes [^(]
to [^("]
to prevent "
from being matched unless it’s part of a complete string.
UPDATE:
@Wiktor Stribiżew commented below:
It still does not support other escape sequences. The first [^("]*
is redundant in the current pattern. It won't match between=("a",,,)
but will match between=("a",,",")
- this is inconsistent. The right regex will match valid double quoted string literals separated with commas and any amount of whitespace between them. The \S+=(\([^(]*(?:[^("]*"(?:[^\\"]|\\["\\])*")(\)))
is not the right pattern IMHO
If you really want the regex to be that robust, you should use a parser, but you could fix those problems by using:
\S+=(\((?:[^("]*"(?:[^\\"]|\\.)*"[^("]*)*(\)))