balancedDelimiters
Matches a balanced sequence delimited by begin and end, ignoring escaped delimiters.
Scans forward starting at position, which must already be past the opening delimiter, and returns the number of characters up to, but not including, the balancing end delimiter. Returns 0 when the delimiters never balance. Nesting is unbounded, and the scan is a single loop, so its stack cost is constant.
Return
the length from position to the matching end delimiter, or 0 if none
Parameters
string
the source to scan
position
the starting index to scan from
begin
the opening delimiter
end
the closing delimiter