Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
What I am trying to do is extract all tables from the source code and parse the data inside the table. I have been able to successfully do this with the following code.
However if I have 2 or more tables in the source (which is very very common) I only get one single table that encompasses all the tables. It is like it sees the first open html tag and then ignores the rest of the close and opens until it gets to the last close html tag.$Txt =~ s!(<table.*?>)(.*|\n)?(</table>)! my $TD = $2; my $first = $1; my $last = $3; unless ($TD =~ /id="CODE"/) { $TD =~ s#<br>#\n#isg; } "$first$TD$last"!eisg;
For example:
This should parse as three seperate matches but it is only recognized as a single match. I know this has to be a simple thing I am overlooking but just can not see it. Any ideas?<table> <tr><td>First Table</td</tr> </table> <table> <tr><td>Second Table</td</tr> </table> <table> <tr><td>Third Table</td</tr> </table>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regexp text parsing issue.
by sh1tn (Priest) on Mar 19, 2005 at 01:12 UTC | |
|
Re: regexp text parsing issue.
by jhourcle (Prior) on Mar 19, 2005 at 01:14 UTC | |
by Anonymous Monk on Mar 19, 2005 at 01:37 UTC | |
by jhourcle (Prior) on Mar 19, 2005 at 02:24 UTC | |
by Anonymous Monk on Mar 19, 2005 at 02:57 UTC | |
by Tanktalus (Canon) on Mar 19, 2005 at 03:00 UTC | |
| |
by jhourcle (Prior) on Mar 19, 2005 at 04:17 UTC | |
by Joost (Canon) on Mar 19, 2005 at 01:53 UTC | |
|
Re: regexp text parsing issue.
by holli (Abbot) on Mar 19, 2005 at 09:51 UTC | |
by sh1tn (Priest) on Mar 19, 2005 at 09:57 UTC | |
|
Re: regexp text parsing issue.
by graff (Chancellor) on Mar 19, 2005 at 15:29 UTC | |
by Anonymous Monk on Mar 19, 2005 at 19:45 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |