I tried
/(^<table)(.*?)($>)/
It should match everything that is between <>
for the table tag, but it does not
I tried
/(^<table)(.*?)($>)/
It should match everything that is between <>
for the table tag, but it does not
As mentioned in the comments on this question, it's not really practical to parse HTML with regular expressions.
Here's an example using Mojo::DOM, inspired by this StackOverflow answer:
#!/usr/bin/env perl
use strict ;
use warnings ;
use Mojo::DOM ;
my $html = <<EOHTML;
<!DOCTYPE html>
<html>
<head>
<title>Sample HTML with a table</title>
</head>
<body>
<table border>
<tr> <td>a</td> <td>b</td> <td>c</td> </tr>
<tr> <td>1</td> <td>2</td> <td>3</td> </tr>
</table>
</body>
</html>
EOHTML
my $dom = Mojo::DOM->new ;
$dom->parse( $html ) ;
for my $div ( $dom->find( 'td' )->each ) {
print $div->all_text . "\n" ;
}
The output is:
a
b
c
1
2
3