Lua patterns support a capture of type %bxy that captures a sequence of
characters with 'x' and 'y' balanced. This can be inappropriate for the
cases where those characters can represent not the "bracket structure" only,
but appear "escaped" as ordinary characters.
I propose a patch that adds a %Bxyz capture type to Lua. It stands for
"sequence of characters with balanced 'x' and 'y' characters where any
character right after a 'z' is treated just as an ordinary character, not
the one to balance".
I have used it to parse Apache log files like this:
str = '"GET /A\\"B HTTP/1.1"'
str:match('%B""\\') -- captures the whole string