in reply to Why isn't my global matching regex working?
Anyway parsing arbitrary html with regex is normally a waste of time.
Please show us some input to help you.
works for me, stripped the useless (but harmless) esacaping
use strict; use warnings; use Data::Dump qw/pp dd/; my $lsdata = do { local $/;<DATA> }; my @table = $lsdata =~ m/(<tr.*?<\/tr>)/g; pp @table; __DATA__ <tr>bla1</tr><tr>bla2</tr> <tr>bla3</tr>
("<tr>bla1</tr>", "<tr>bla2</tr>", "<tr>bla3</tr>")
so better inspect your input again!
Ah wait ... I think you need an /s modifier to make . match newlines !!!
use strict; use warnings; use Data::Dump qw/pp dd/; my $lsdata = do { local $/;<DATA> }; my @table = $lsdata =~ m/(<tr.*?<\/tr>)/sg; pp @table; __DATA__ <tr>bla1</tr><tr>bla2</tr> <tr>bla3</tr> <tr> bla4 </tr>
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why isn't my global matching regex working? (update: /s modifier)
by jdseymour (Initiate) on Apr 15, 2018 at 15:27 UTC |