I have am using regex.replace to replace a ‘#’ character with a Environment.Newline.
However it is not returning the expected results. It is just returning the same input string.
Here is my code.
Regex.Replace(inputString, @"#", Environment.NewLine);
Regex.Replacedoesn’t change the parameter you passed in. It returns the results as a new string.Try this:
Of course, Regex is a bit overkill for such a simple replacement.
String.Replacewould be enough in that case (note:String.Replacealso doesn’t modify the parameter, but returns a new string).