I have the following C# code to replace .‘s and +‘s with spaces:
string MyString = "this.is.just+an++example--here!are$more characters";
MessageBox.Show(Regex.Replace(MyString, @"[\.\+]", " "));
Sometimes this might result in excess whitespace (as in, between an and example).
How can I also add the following RegEx to my existing RegEx, so there is only a single RegEx call?
Regex.Replace(MyString, @"[ ]{2,}", " ");
This will remove excess whitespace. All other characters should remain untouched.
Any alternate solutions are also welcome!
Maybe you should match multiple characters in the first place. Change the regexp to
"[\.\+]+"to match one or more.or+signs. For example,"a...++b"would result in"a b"