I want to split the string first with "duration=" and the remaining part of the string, with the code below Im able to do that. Now I want to check if the second part of the string is containing any comma(,) and split that values accordingly
String data = "duration=WEEKLY,MONTHLY";
pattern = Pattern.compile("duration=(\\S*),(\\S*)", Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(data);
if (matcher.find()) {
System.out.println(matcher.group(2)); //this prints MONTHLY(as it is group(2))
}
I want to print "WEEKLY,MONTHLY". How can I get the entire string?
matcher.toMatchResult() or matcher.toString() returns the object instance.
Any help would be highly appreciated. Thanks