I'm learning about quantifier and facing problem to understand the Reluctant and Possessive. I read a lot answers from the stackoverflow, oracle documentation and even found good image https://i.stack.imgur.com/DyhJk.png that is describing them in visually. But still confused. Here is my code.
Pattern p = Pattern.compile("a*?");
Matcher m = p.matcher("abclaaakditabdaa");
while(m.find()){
System.out.println(" Word: " + m.group() );
}
Why this code is not giving output?
My Understanding:
As in image I understand that Reluctant first match the complete string if it not matched then it start from the left side and move to right side by one character. So in my example it will not match the entire string then it will start from the left side to match. So in my example it should print
a
aaa
a
aa
Can you describe what is wrong with my understanding?