I expected this to print "[b]"
but it prints "[]"
:
$x = "abc";
$x =~ /(b*)/;
print "[$1]";
If the star is replaced with a plus, it acts as I expect. Aren't both plus and star supposed to be greedy?
ADDED: Thanks everyone for pointing out (within seconds, it seemed!) that "b*" matches the empty string, the first occurrence of which is before the string even starts. So greediness is not the issue at all. It matches the empty string before even getting to the first 'b'.