Regular Expressions: Remove all special characters from a string, allowing only alphanumeric and chars: ‘.’ and ‘-’
Remove all special characters from a string, allowing only alphanumeric and chars: ‘.’ and ‘-’
Example:
string source = ".ąśę0123^%($&Marek&*(@&@#-"; string result = System.Text.RegularExpressions.Regex.Replace(source, @"[^\w\.-]", ""); // result= ".ąśę0123Marek-"

(2,898)


Worked great in java, thanks!!
str = str.replaceAll(“[^\\w\\.-]“, “”);