I am trying to use a regular expression that outputs data from a string like
<B Att="text">Test</B><C>Test1</C>
The output selected should be Test and Test1. This is what I have done so far:
public class HelloWorld {
public static void main(String[] args)
{
String s = "<B>Test</B>";
String reg = "<.*?>(.*)<\\/.*?>";
Pattern p = Pattern.compile(reg);
Matcher m = p.matcher(s);
while(m.find())
{
String s1 = m.group();
System.out.println(s1);
}
}
}
But this leads to a result <B>Test</B>. Can someone point out what I'm doing wrong?
Asha source
share