My Value 1
I need "My Value 1" Please Help Me. C# language
My Value 1
I need "My Value 1" Please Help Me. C# language
As HTML code is very "unpredictable" I would recommend using a HTML parsing kit. Which programming language do you use? In .NET I have used HTML Agility Pack with great success. In Java HTML Parser might be handy (though I have not worked with it yet).
You cannot properly parse HTML with regular expressions because regexps can't handle the nesting allowed by HTML. To do it properly. For that one line you show, you can use a regexp but you can't count on that line remaining identical so must use SAX/DOM for the task generally.
I think parsing HTML using Regexes is not a wise idea, as highlighted by spa. A classic previous answer to a similar question is RegEx match open tags except XHTML self-contained tags
Try:
/<tr>\s*<td>\s*<font.*?>(.*?)<\/font>\s*<\/td>\s*<\/tr>/i
Used in PHP:
<?php
if(preg_match('/<tr>\s*<td>\s*<font.*?>(.*?)<\/font>\s*<\/td>\s*<\/tr>/i',
'<tr><TD><FONT size="2">My Value 1</FONT></TD></tr>',$matches))
echo $matches[1]; // prints My Value 1
?>
If you want to get the contents within the tags I think the following Regexp is enough:
^<.*>([^<>]+)<.*>$
It will only work if there really is any data between the tags somewhere, otherwise it will give a no-match.