I want to replace and insert escape character sequences with their escape character values, also taking into account that '\' nullifies the escape character.
For example
"This is a \n test. Here is a \\n which represents a newline"
What is the easiest way to achieve this in Ruby?