#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
 
# Capture the number, and use a back-reference in the {} to define how many characters to match
my $myString = "1abc3cdfg\n"; 
$myString =~ s/(\d+)(??{ ".{$^N}" })//g;
say $myString;