0

I am new to asp.net can you help me to find out how to find and extract the numbers from string in Asp.net.

2 Answers2

0
string output = new string(input.Where(char.IsDigit).ToArray()); 
Damith
  • 62,401
  • 13
  • 102
  • 153
0

Method 1:

       String str = "udsdf34dfd78"; /*any string*/
       String strNumber = "";
       Regex regex=new Regex(@"\d");

       foreach (Match m in regex.Matches(str))
           strNumber += m.Value;

Method 2:

              String str = "udsdf34dfd78"; /*any string*/
              String strNumber = ""; 
              foreach (Char c in str)
               if (Char.IsDigit(c))
                   strNumber += c.ToString();
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67