Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Search for consecutive flush left curly braces

by MarkusLaker (Beadle)
on Jun 10, 2015 at 15:11 UTC ( #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? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2023-03-29 19:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (72 votes). Check out past polls.

    Notices?