The code
String s = "y z a a a b c c z";
Pattern p = Pattern.compile("(a )+(b )+(c *)c");
Matcher m = p.matcher(s);
while (m.find()) {
System.out.println(m.group());
}
prints
a a a b c c
which is right.
But logically, the substrings
a a a b c
a a b c c
a a b c
a b c c
a b c
match the regex too.
So, how can I make the code find those substrings too, i.e. not only the most extended one, but also its children?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…