Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Search for consecutive flush left curly braces

by MarkusLaker (Beadle)
on Jun 10, 2015 at 15:11 UTC ( [id://1129873]=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re^2: Search for consecutive flush left curly braces
by ExReg (Priest) on Jun 10, 2015 at 16:31 UTC
    Thanks! Exactly what I was looking for. I am humbled by your wisdom and in awe of the beauty of your answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1129873]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found