my $ariths = '(+*\-/<>=)%^'; $string =~ s/(?:^|(?<=[$ariths]))BAD(?=[$ariths])/HELL/g;