in reply to Finding Start/End Position of the Uppercase Substring

Using your convention of the first letter in the string being 1, rather than the Perl way of 0. if you want to do anything in Perl with theses numbers you need to subtract one from both the start and end offsets.

# 1 2 3 # 123456789012345678901234567890 my $str_type1 = "ccaatTTTGACACACACAGAAgggca"; # no dash my $str_type2 = "--aatTTTGACACACACAGAAgggca"; # with dash for ( $str_type1, $str_type2 ) { if ( m{^(-*)[^A-Z]*([A-Z]*)} ) { my ( $s, $e ) = ( $-[2] + 1, $+[2] ); $_ -= length $1 for $s, $e; print "$_\n"; print "From = $s to $e\n\n"; } } #output: ccaatTTTGACACACACAGAAgggca From = 6 to 21 --aatTTTGACACACACAGAAgggca From = 4 to 19