You want something like this:
r"'([^']|'')*'"
This suggests that inside single quotes, you can have either double quotes or a character without quotes.
Brackets define a character class in which you specify characters that may or may not match. This does not allow anything more complicated, therefore, trying to use parentheses and match a multi-character sequence ('') does not work. Instead, your character class [^('')] equivalent to [^'()] , i.e. Matches any that is not a single quote, nor a left or right bracket.
John kugelman
source share