#!/usr/bin/perl use strict; use warnings; my $S = 'Hello World 123456 !!! 789 ...'; my $P = 14; # $P points to digit '3' # I want to capture 123456 but I can only capture 3456 with this regex: my $INT = ($S =~ m/^.{$P}(\d+)/) ? $1 : ''; print "\n :$INT: \n";