c# filter non alphanumeric characters

C#
Regex rgx = new Regex("[^a-zA-Z0-9 -]");
str = rgx.Replace(str, "");
Source

Also in C#: