Confusion in RegExp Reluctant quantifier? Java
- by Dusk
Hi,
Could anyone please tell me the reason of getting an output as: ab for the following RegExp code using Relcutant quantifier?
Pattern p = Pattern.compile("abc*?");
Matcher m = p.matcher("abcfoo");
while(m.find())
System.out.println(m.group()); // ab
and getting empty indices for the following code?
Pattern p = Pattern.compile(".*?");
Matcher m = p.matcher("abcfoo");
while(m.find())
System.out.println(m.group());