Do not use regular expression delimiters:
name = Regex.Replace(name, @"\W", "");
In C #, you cannot use regular expression delimiters because the syntax for declaring a regular expression is different from PHP, Perl or JavaScript, or others that support <action>/<pattern>(/<substituiton>)/modifiersregex declarations .
, : ( , , , ), , RegexOptions ( RegexOptions , ). , , . , ; , .
# , , . Perl- s/\W//g var replaced = Regex.Replace(str, @"\W", string.Empty);. .