Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by hippo (Bishop)
on Mar 06, 2021 at 11:01 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found