# test string my $link_results = '

Hello: World Hello hello drewboy Drewboy: Drewboy!

'; # define an array of the terms we want to bold my @terms = ( 'Hello:', 'Drewboy!' ); # make all the terms regex safe by quotemeta-ing them $_ = quotemeta $_ for @terms; # join all terms with a pipe | so we find any of them - alternation my $bold = join '|', @terms; # make all the subs - case sensitive and global $link_results =~ s#(<[^>]+?>)|($bold)#$1 ? $1 : "$2"#eg; # proof is in da pudding print $link_results;