note
JediWizard
<p>Try this:</p>
<code>#!/usr/local/bin/perl
$re = qr@
\{
(?:
(?> [^{}]+ ) # Non-{} without backtracking
|
(??{ $re }) # Group with matching {}
)*
\}
@x;
my $string = 'value:patternList = "{error 1 1 {^E 0-20-9:0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0-50-9.*$}} {three 1 1 {^.*35=A.*$|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}} {fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*VFIXFxProxy.*Disconnected}"';
while($string =~ m/$re/g){
print "$&\n";
}
exit;
__END__
output:
{error 1 1 {^E 0-20-9:0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0-50-9.*$}}
{three 1 1 {^.*35=A.*$|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}}
{fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*VFIXFxProxy.*Disconnected}
</code>
<p>See [doc://perlre]</p>
<div class="pmsig"><div class="pmsig-391471">
<hr />
<p>They say that time changes things, but you actually have to change them yourself.</p><p class='indented'>—Andy Warhol</p>
</div></div>
490582
490582