There will be situation when we need to remove special or hidden characters from a string. Below code will help you to chive the same.
C#
C#
string output =
new string(input.Where(c => !char.IsControl(c)).ToArray());
or
string output = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray());
//if which to take only letters and
//if which to take only letters and digits
VBDim cleanString As String = Regex.Replace(yourString, "[^A-Za-z0-9\-/]", "")
No comments:
Post a Comment