I've tried new Regex("a-zA-Z0-9").Replace(myString, string.Empty) but apparently that is not correct.
2 Answers
The correct regex would be [a-zA-Z0-9].
The regular expression a-zA-Z0-9 matches the literal string a-zA-Z0-9 whereas the character class [a-zA-Z0-9] matches any of the characters in the ranges a-z, A-Z or 0-9.
In addition, these classes have shorthands (sort of).
\drepresents the class of digits, that is[0-9].\wrepresents the class of alphanumerical characters, as well as underscore, that is[0-9A-Za-z_].
Useful links:
1 Comment
Jake Petroules
Thanks, I knew I was missing something simple. ;) +1