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


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';

🦛