This should work. Change the "number of characters" as per your need.You need to modify the code as per your need
#!/usr/bin/perl
use strict;
use warnings;
my $str = ".,a..A,,C..+4ACGTG.,-2TG,,...,a";
$str =~ s/[+-]?\d\w{4}//g;
$str =~ s/[+-]?\d\w+//g;
print $str;
Update 1: Eliya's method works awesomely well. I learnt something today. Thanks Eliya
Update 2: After several tries, I got this regex and it should also work
#!/usr/bin/perl
use strict;
use warnings;
my $str = ".,a..A,,C..+4ACGTG.,-2TG,,...,a";
$str =~ s/[+|-](\d*)(\w*)/(substr $2, $1)/ge;
print $str;
|