I had a case today where I needed to “escape” characters which were to be built as part of a regular expression string. This was required in case the string built into the regular expression used any “reserved” characters used by the Regex engine.
Below is the code used in C# and JavaScript notation:
C#:
private string [...]