m#<TD>(.*?)</TD>#g
This will return a list of all the matches.
You can then select whichever term you want from the list:
my $html = "<TR><TD>Foo:</TD><TD> bar </TD></TR>";
my $var = ( $html =~ m#<TD>(.*?)</TD>#g )[1];
Note that you have to modify the
asterisk with the question mark to specify non-greedy matching.
If you don't, you will get just one big match, like
Foo:</TD><TD> bar
— probably not what you wanted!
You should also add the /s modifier, if the string you need to extract breaks across multiple lines.
Specifically, /s allows the dot to match newline characters along with all the other characters.
|