c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $s = 'abCdefC'; print '01234567'; print $s; print '------------'; ;; while ($s =~ / (f)*? C /gx) { printf qq{matched (f) of %s then C at pos of %d \n}, pp($1), pos $s; } ;; print '------------'; ;; while ($s =~ / (f*?) C /gx) { printf qq{matched (f) of %s then C at pos of %d \n}, pp($1), pos $s; } " 01234567 abCdefC ------------ matched (f) of undef then C at pos of 3 matched (f) of "f" then C at pos of 7 ------------ matched (f) of "" then C at pos of 3 matched (f) of "f" then C at pos of 7 #### c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $s = 'xxfxx'; print '012345'; print $s; print '------------'; ;; while ($s =~ / (f)*? /gx) { printf qq{matched (f)*? of %s, starting at offset of %s, ending at pos of %d \n}, pp($1), pp($-[1]), pos $s; } ;; print '------------'; ;; while ($s =~ / (f*?) /gx) { printf qq{matched (f*?) of %s, starting at offset of %s, ending at pos of %d \n}, pp($1), pp($-[1]), pos $s; } " 012345 xxfxx ------------ matched (f)*? of undef, starting at offset of undef, ending at pos of 0 matched (f)*? of undef, starting at offset of undef, ending at pos of 1 matched (f)*? of undef, starting at offset of undef, ending at pos of 2 matched (f)*? of "f", starting at offset of 2, ending at pos of 3 matched (f)*? of undef, starting at offset of undef, ending at pos of 3 matched (f)*? of undef, starting at offset of undef, ending at pos of 4 matched (f)*? of undef, starting at offset of undef, ending at pos of 5 ------------ matched (f*?) of "", starting at offset of 0, ending at pos of 0 matched (f*?) of "", starting at offset of 1, ending at pos of 1 matched (f*?) of "", starting at offset of 2, ending at pos of 2 matched (f*?) of "f", starting at offset of 2, ending at pos of 3 matched (f*?) of "", starting at offset of 3, ending at pos of 3 matched (f*?) of "", starting at offset of 4, ending at pos of 4 matched (f*?) of "", starting at offset of 5, ending at pos of 5