This regex matches a single one-line C-like string literal. The parsing rules are almost exactly the same as C string literals:
- A string literal can be surrounded by either single or double quotes, but they must match.
- In a double quoted string, single quotes can optionally not be preceded by a backslash. And vice versa.
- In a double quoted string, double quotes must be escaped. And vice versa.
- Backslashes themselves must be escaped.
- Any character but a newline, line-feed, or space can follow a backslash, so this regex can be used with any programming language.
The group <begin_quote>
stores the quote character that the string literal is surrounded with.