如何从仪表板,除了字符串中删除所有非字母数字字符?

问题描述:

我如何删除字符串中的所有非字母数字字符,除了仪表板和空格字符?

How do I remove all non alphanumeric characters from a string except dash and space characters?

替换 [^ A-ZA-Z0-9 - ] 为空字符串

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