Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Matching a string in a parenthesized block (regex help)

by hippo (Chancellor)
on Mar 06, 2021 at 11:01 UTC ( #11129187=note: print w/replies, xml ) Need Help??


in reply to Matching a string in a parenthesized block (regex help)

This works for me. See also How to ask better questions using Test::More and sample data.

use strict; use warnings; use Test::More tests => 2; my $in = <<EOT; ASDF { tmp foo_match tmp } string2 { tmp } string3 { tmp bar_match tmp } EOT my $re = '^ASDF {[^{]*foo_match[^}]*}'; like $in, qr/$re/m, 'foo_match found in ASDF'; $re =~ s/foo/bar/; unlike $in, qr/$re/m, 'bar_match not found in ASDF although present in + string3';

🦛

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2021-04-16 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?