my $string = "smasm"; if ( $string =~ /(.).*\1$/ ) { print "$1" ; #match a double char }