Link to home
Start Free TrialLog in
Avatar of JonMny
JonMny

asked on

Remove numbers from string regex

I need to remove numbers from strings like

Data1

Date3Last

so that i end up with

Data and DateLast


Using c# regex...
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
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
Hi JonMny;

When using the Regex.Replace method you need to assign the return value of that function to a variable or itself as shown below.

List<string> stripdigits = new List<string>();
stripdigits.Add("Data1");
stripdigits.Add("Date3Last");

for (int idx = 0; idx < stripdigits.Count; idx++)
{
    stripdigits[idx] = Regex.Replace(stripdigits[idx], @"\d+", String.Empty);
}

Fernando