% perl -le 'print $& if shift =~ /(\d)(((??{$^N + 1})))+/' 4321234 1234 % #### (((??{$^N + 1})))+ matches null string many times before HERE mark in regex m/((\d)(((??{$^N + 1})))+ << HERE )/ at -e line 1.