$str =~ m/\A(.).*(.)\z/xms; my $first_character = $1; my $last_character = $2;