[Solved] Remove all symbols different from numbers and letters in string [duplicate]


This should work:

var result = new Regex("[^a-zA-Z0-9 ]").Replace(address, string.Empty);

This keeps only whatever in a-Z, A-Z or 0-9 or white space

You can also use linq:

var result2 = new String(address.Where(x => char.IsLetterOrDigit(x) 
                                         || char.IsWhiteSpace(x)).ToArray());

4

solved Remove all symbols different from numbers and letters in string [duplicate]