How to get only alpahabets in a text

I have a input 456789SD56-789

I Need to get only alpahabets from there

ie.SD

try using this expression in an assign, or through regular expression:

var output = Regex.Replace(input, @"[\d-]", string.Empty);

Using \d matches any numbers and the string.Empty removes them, you can also replace the “-” with empty string too

grafik
System.Text.RegularExpressions.Regex.Replace(YourStringVar,"[^\p{L}]","")

in this statement we do replace anything what is not a letter with a blank

Hi @aquinn

How about this expression?

System.Text.RegularExpressions.Regex.Replace(YourString,"\d+|\W","")

Regards
Gokul

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.