# updated, thanks to PerlMouse -- not using \b, though! $str =~ s/(^|,)42(,|$)/$1 && $2/e