$string =~ s/([^\])\'/$1\\\'/g; [download]
In reply to Re: finding ' by mfriedman in thread finding ' by Anonymous Monk