in reply to how to escape ' character

Please, see
perldoc -q escape
s/(')/\\$1/g;