icanwin has asked for the wisdom of the Perl Monks concerning the following question:
my $text1 = qq{ <div id="aaaa"> text tex text <ul id="ccc">bla bla bla</ul> more text </div> }; my $text2 = qq{ <div id="aaaa"> text text text more text </div> }; my $regex = '<div id="aaaa">(.*)<ul id="ccc">(.*)</ul>(.*)</div>'; if ( $text1 =~ /$regex/sg ) { warn "Text 1 found ".$1.$3; } if ( $text2 =~ /$regex/sg ) { warn "Text 2 found ".$1.$3; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Advanced regular expression help
by moritz (Cardinal) on Sep 12, 2008 at 11:13 UTC | |
by Andrew Coolman (Hermit) on Sep 12, 2008 at 18:16 UTC | |
|
Re: Advanced regular expression help
by wfsp (Abbot) on Sep 12, 2008 at 15:55 UTC |