Im trying to insert literal strings into c++ files using a c# tool, and Im tasked with automatically adding escapes.
To start with " => \". However I cannot figure out the regular expression required to transform instances of " to \"
public String AddEscapeCharactersForCode(String content)
{
String escaper = "\\\\";
String ncontent = Regex.Replace(content, "\\\\\"");
ncontent = Regex.Replace(ncontent, "'", "\\\\'");
ncontent = Regex.Replace(ncontent, "\n", "\\\\\n");
return content;
}
The above code does nothing to my strings resulting in unescaped quotes and broken code files =(