I have an HTML page and I want to fetch the result between two tags <b>
and <BR>
:
<b>Defendants Name:</b>Donahue, Leah A <BR>
What is the regular expression to fetch the words between these two tags?
I have an HTML page and I want to fetch the result between two tags <b>
and <BR>
:
<b>Defendants Name:</b>Donahue, Leah A <BR>
What is the regular expression to fetch the words between these two tags?
See http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
I think this could work:
String str = "<b>Defendants Name:</b>Donahue, Leah A <BR>";
Pattern pattern = Pattern.compile(".*<b>(.*)<BR>.*", Pattern.UNIX_LINES);
Matcher m = pattern.matcher(str);
if (m.matches() == true)
{
System.out.println(m.group(1));
}
And should print
"Defendants Name:Donahue, Leah A " (excluding the quotes).