Very sad, but such an elegant and accurate way does not work:
(["'])(?:\\\1|[^\1]+)*\1
But we can change it a little bit, and all works fine:
(["'])((?:\\\1|(?:(?!\1)).)*)(\1)
https://regex101.com/r/dKdBMT/2
I would like to make sure that this regexp will work in all cases: please more test it.