Is there a better way to replace strings?
I am surprised that Replace does not take in a character array or string array. I guess that I could write my own extension but I was curious if there is a better built in way to do the following? Notice the last Replace is a string not a character.
myString.Replace(';', '\n').Replace(',', '\n').Replace('\r', '\n').Replace('\t', '\n').Replace(' ', '\n').Replace("\n\n", "\n");
You can use a replace regular expression.
s/at the beginning means a search[and]are the characters to search for (in any order)/delimits the search-for text and the replace textIn English, this reads:
“Search for
;or,or\tor\ror(space) or exactly two sequential\nand replace it with\n“In C#, you could do the following: (after importing
System.Text.RegularExpressions)