I'm trying to leverage regex to extract information that exists between double quotes in every line of a configuration file. I'm okay with some basic level regex, but when it comes to complex ones; especially involving capture groups I keep running into brick walls despite trying to test and research via regex101.com.
my $text = '
"Key1" = { StuffIDontCareAbout = "Value1" },
"Key2" = { StuffIDontCareAbout = "Value2" },
"Key3" = { StuffIDontCareAbout = "Value3" },
"Key4" = { StuffIDontCareAbout = "Value4" },';
my %hash = undef;
for (split/\n/,$text) {
my $pattern = qr/(")(?:(?=\\?))\2.)*?\1/;
$hash{$1} = $2 if (/$pattern/);
}
print Dumper \%hash;
On regex101.com the information I care about is highlighted; however in my perl script $1 = " & $2 = null.
I think I need to match quotes with non-capture groups so that the first and second capture group is everything between them, however I can't figure it out.
Thanks in advance.