I have a Question in regex Expressions.
I want to make nested same values into a single group.
But,I was trying to using regular expression i won't work.
Example String:
<one listtype="NumberList1">one</one>
<one listtype="NumberList1">one</one>
<one listtype="NumberList1">one</one>
I want to get the three <one></one> tag as a single group.
How can I do this??
My regex pattern is:
Pattern pattern = Pattern.compile("(<one (.*?)>(.*?)</one>)+");
Matcher matcher = pattern.matcher(val);
while (matcher.find()) {
System.out.println("group 1: " + matcher.group(1));
}
My result is:
group 1:<one listtype="NumberList1">one</one>
group 1:<one listtype="NumberList1">one</one>
group 1:<one listtype="NumberList1">one</one>
I want:
group 1:<one listtype="NumberList1">one</one><one listtype="NumberList1">one</one><one listtype="NumberList1">one</one>
I want to make this as a single group.
How can i do this?