capture a string with escape using negative lookbehind (?<!x)
※ This method is incomplete because it only concerns the case there is only one backslash before a quotation mark.
In real life, there mabe more thatn one backslashes before the quotation mark.
/".*?(?<!\\)"/su
- .*? instructs a lazy repetition: it trys to get out of repetition as soon as it can.
- \\\\ will be \\ in php and it will be \ in regex
- (?<!x)y is negative look behind. matches 'y' that is not proceded by 'x'
123"abc"defg"xyz"456 = true : "abc"
123"abc\"defg"xyz"456 = true : "abc\"defg"
123"abc\"defg\"xyz"456 = true : "abc\"defg\"xyz"