Using LINQ to parse the numbers from a string

前端 未结 7 1477
忘掉有多难
忘掉有多难 2021-02-19 22:00

Is it possible to write a query where we get all those characters that could be parsed into int from any given string?

For example we have a string like: \"$%^DDFG

7条回答
  •  野性不改
    2021-02-19 22:43

    public static string DigitsOnly(string strRawData)
      {
         return Regex.Replace(strRawData, "[^0-9]", "");
      }
    

提交回复
热议问题