in reply to string escaping / de-escaping functions
There are domain specific solutions (\Q and \E for regex escaping, Encode for character encoding, HTML::Entities and so on), but a regex is the general answer to the general problem.