If you are a regular follower of my blog you will have no doubt worked out I am doing some development over the last week and have been wrestling with various problems.
Today I found one of my columns had special characters such as Newline, carrage return etc and I wanted to remove them. In the end I had to make this function and it did the job just fine. I’m sure I have come across this problem before and I thought I had a better solution but searching on google and I couldn’t find anything.
public static string ReplaceNewlines(string blockOfText, string replaceWith) { return blockOfText.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith).Replace("\t", replaceWith); }