$string=~s/([b-w]+)[^a]+([a]+)/uc($1)." foo ".uc($2)/ge; $string=~s/([b-w]+)[^a]+([a]+)/\U$1\E foo \U$2\E/g; # without /e