http://qs321.pair.com?node_id=1129873


in reply to Search for consecutive flush left curly braces

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"); }