my $str="a apple"; $str =~(s/a(\s+[aeiou].+)/an\1/g); print $str