Confusion in RegExp Reluctant quantifier? Java
Posted
by Dusk
on Stack Overflow
See other posts from Stack Overflow
or by Dusk
Published on 2010-05-14T11:21:01Z
Indexed on
2010/05/14
11:24 UTC
Read the original article
Hit count: 254
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());
© Stack Overflow or respective owner