How to Replace Number from a String in C#

Consider following is my string.

  1. String myString = "MyString1";  

And I need to take out the number 1 from the value MyString1. What will we do?

To do this we can use Regex class in C#. Following is the code to achieve the same

  1. myString = Regex.Replace(sortdatafield, @"[\d-]", string.Empty);  
Once you done and Run, you will get the new value without numbers (“MyString″) in the variablemyString
 
Kindly see my code snippets here

I hope someone found this useful. Happy Coding

Kindest Regards
Sibeesh Venu