hi there
I have a
string = "<a><b>qwer qwer</b></a><b>zxcv zcv</b>"
I want output as follows
<b>qwer qwer</b>
<b>zxcv zcv</b>
I tried following but the problem is i m getting output as <b>qwer qwer</b></a><b>zxcv zcv</b>
String newLine = System.getProperty("line.separator").toString();
String input = "<a><b>qwer qwer</b></a><b>zxcv zcv</b>";
String output = "";
String regex = "<b>.*</b>";
Pattern p1 = Pattern.compile(regex);
Matcher m1 = p1.matcher(input);
while (m1.find())
{
output += m1.group() + newLine;
}
//System.out.println("input = " + input);
System.out.println("output = "+output);
Can anyone suggest a solution for this ?
Basically because i m using .* so it goes on parsing the string and doesn't stop when it finds first match.
Can somebody tell how to do this ?
Thanks a lot in advance