String replace

NekoManu

Well-known member
Joined
Jul 23, 2004
Messages
75
Location
Belgium
I have a string and I want to remove anything that is not a letter. I know I can use the replace method, but then I have to check for everything. I hope there is a better way of doing this.
 
Check out MSDN on "Regex.Replace()". Looks like their sample does a reimplementation of ToUpper(), but you can slightly modify that code in CapText() to return an empty string.
 
Thanks I seems to work. Here is how to get rid of anything that is not a letter:

Regex.Replace(InString, @"[^a-zA-Z]", "")
 
Back
Top