Link to home
Start Free TrialLog in
Avatar of JonMny
JonMny

asked on

Regex return only letters

how can I return only  letters A-Z from a string using regex. if I have a string like "abcdef^&%0087" I only want . abcdef

C#
Avatar of silemone
silemone
Flag of United States of America image

you could use RegEx replace...


replace all other characters that aren't chars with ""...
string word ="";
word= myStr.Replace("[0-9](_&*?", "");
ASKER CERTIFIED SOLUTION
Avatar of silemone
silemone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i know you gave me the points already, but this is the perfected version:

using using System.Text.RegularExpressions;
on my aspx page i have a text box - txt that the user inputs string to modify in...

you can just use strings in place of the text box...

basically says remove anything that is not alphabets - make everything else empty string - ""

 txt.Text = Regex.Replace(txt.Text.ToString(), @"[^a-zA-Z]", "");
cheers..