You could use a regular expression with the /g modifier:
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
— probably not what you wanted!Foo:</TD><TD> bar
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.
In reply to Re: How can I find the contents of an HTML tag?
by nuance
in thread How can I find the contents of an HTML tag?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |