Does this do what you need?
#!/usr/bin/perl
use warnings;
use strict;
use v5.10.0;
my $rx_consecutive = qr/
^ }
(?:
(?! ^ [{}] )
.
)*
^ }
/msx;
my @strings = split /!/, <<'STRINGS';
f()
{
fred();
}
g()
{
jim();
}
!
f()
{
fred();
}
int i = 0;
}
g()
{
jim();
}
!
f()
{
if (i) {
fred();
}
}
g()
{
jim();
}
STRINGS
for my $text (@strings) {
say "Testing:\n$text\n";
my $found = $text =~ $rx_consecutive;
say "Double right-curly ", ($found? "found": "not found");
}
|