in reply to Regex question
$string =~ s/\b($greekReplace)\b/\\$1 /isg;
Note that \b doesn't think 3mu has a word boundary between the 3 and mu (because both match \w). If that's a problem, you need to work with the look-around assertions described in perlre.
Update: I should have read the question more carefully, it seems a negative look-behing would be more appropriate:
s/(?<!a)($greekReplace)/\\$1 /isg;
|
|---|