Here is the scenario, I have this regex pattern:
\"category\",([0-9]+)\n(\"subcategory\",[0-9]+\n)*
this pattern should match the following data:
"category",1
"subcategory",1
"subcategory",2
"subcategory",3
"category",2
"subcategory",1
"subcategory",2
"subcategory",3
and I'm using the following regex function:
public static List<String> regexFindMultiStrings(String pattern, String input) {
Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(input);
List<String> data = new ArrayList<String>() ;
while (m.find())
{
for (int i = 0; i <= m.groupCount(); i++)
{
data.add(m.group(i));
//Log.e("Array", m.group(i));
}
}
return data;
}
here is the problem, now when I use this pattern to match all the data it gives only the following:
1
"subcategory",1
2
"subcategory",1
which is something I'm not looking for how to get all of the data something like:
1
"subcategory",1
"subcategory",2
"subcategory",3
2
"subcategory",1
"subcategory",2
"subcategory",3