I have a string and a pattern that I want to search for in that string. Now, when I match the pattern in the string, I want to know the string that matches my pattern.
String template = "<P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT></P>";
String pattern = "<FONT.*>";
Pattern.compile(pattern,Pattern.CASE_INSENSITIVE);
How can I find out the string that matches the pattern in my template.
i.e I want to get <FONT FACE=\"Verdana\" SIZE=\"12\">
as the result. Is there any method provided by the regex library in Java which can help me?
Update:
What is the regular expression that can match <FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT>
and <LI><FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT></LI>
and it should not be greedy in a given text.