Match any char inside two quotation pairs, including nested quotations

I have data that will appear as dual quotation pairs like this, per line.

"Key" "Value"

Inside of these pairs there can be any character, and sometimes there comes the dreaded "" nested pair:

"Key "superkey"" ""Space" Value"

Previously I've found: "([^"]*)"\s*"([^"]*)" And this matches Key and Value to two groups:

$1 = Key
$2 = Value

But, with the nested pairs, it will only output:

$1 = superkey

Is there a way to match all characters between the pairs? Example output wanted:

$1 = Key "superkey"
$2 = "Space" Value

Regular expression processing from QRegularExpression and c++11 Literal string:

QRegularExpression(R"D("([^"]*)"\s*"([^"]*)")D");

I know it matches Pearl and PHP regex.

Answers


"(.*?)"[\t\r ]+"(.*?)"(?=[ ]*$)

Try this.See demo.

https://regex101.com/r/hR7tH4/2


Need Your Help

Splitting date regex

regex pipe yahoo

Hi I'm trying to split the format of the date YYYY-MM-DD to seperate variables in yahoo pipes.

How does Ractive's proxy-load work?

javascript jquery ractivejs

I want to know when a DOM element generated by Ractive is ready. In my case, I want to use jquery to attach an autocomplete function onto the element. Ideally it would go something like this: