I am looking for a regular expression to remove all special characters from a string, except whitespace. And maybe replace all multi- whitespaces with a single whitespace.
[ ](?=[ ])|[^-_,A-Za-z0-9 ]+
Try this.See demo.Replace by empty string
.See demo.
http://regex101.com/r/lZ5mN8/69
Use the regex [^\w\s]
to remove all special characters other than words and white spaces, then replace:
Regex.Replace("[one@ !two three-four]", "[^\w\s]", "").Replace(" ", " ").Trim