mercredi 24 décembre 2014

declare an advance regex pattern in c#

I wanted to remove all the non alphanumeric characters from my string, to do that I used this :



Regex rgx = new Regex("[^a-zA-Z0-9 -]");
string newString = rgx.Replace(oldString, "");


However, I have now a new constrainst which is to keep in addition to the alphanumeric characters, the apostroph character "'";


Example : For this string "abcd1*%'", I would like to get "abcd1'".


Thanks in advance for your help.


Aucun commentaire:

Enregistrer un commentaire