$term1 = 'Tesla S|Tesla model V|Tesla model|TESLA'; $term2 = 'Ford RAM truck|2020 Ford Mustand|Ford ranger|Ranger|ford|2020 Ford F-250|2020 Ford F250|Ford F 250'; term1 =~ s/\-/ /g; term2 =~ s/\-/ /g; $input = '... 2020 Ford F 250 is great but I prefer Tesla Model-V ...'; $input =~ s/\-/ /g; $input =~ s/($term1)/\<1\>\<$1\>/ig; $input =~ s/($term2)/\<2\>\<$1\>/ig; . .