The case is that, I want to find string which satisfies "c+d" in a string "cccd". My code is as follows,
String str="cccd";
String regex="c+d";
Pattern pattern = Pattern.compile(regex);
Matcher matcher =pattern.matcher(str);
While(matcher.find()){
System.out.println(matcher.group())
}
The result is only "cccd". But what I want is to get all the possible results, including nested ones, which are cd, ccd and cccd. How should I fix it, thanks in advance.