Wednesday, August 8, 2012

Remove all special characeter in String.


Remove all special characeter in String.
string title = "You, should be <careful. with , (your current approach) ";
title = Regex.Replace(title, "[^0-9a-zA-Z]+", " ");

Output:
You should be careful with your current approach

Regex.Replace(title, "[^0-9a-zA-Z]+", ""); -- also Remove Space.

Output:
Youshouldbecarefulwithyourcurrentapproach

No comments:

Post a Comment