Perl RE global matching is not working /.*(11).*/g

I have a file containing this single line:

111112111122113

I want to match all two element sequences of 1 in all occurrences.

But when I try this $ perl -lne 'print $1 if /.*(11).*/g' u I get only one result despite the presence of g at the end of my RE:

11

enter image description here How do I print them all, what's wrong with my RExp ?


Use the non greedy quantifier:

perl -lne 'print $1 if /.*?(11)/g'
#                 here ___^

Demo & explanation

But I think you'd better use a loop:

print $1 while ($inputline =~ /.*?(11)/g)