用正则表达式截取字符串中的数字

用截取字符串中的数字,代码如下:

double d = 0;
            string str = "hello8023.1314world"; //要截取的字符串
            Match m = Regex.Match(str, "\d+(\.\d+){0,1}");
            double.TryParse(m.Groups[0].ToString(), out d);
            Console.WriteLine(d);
            Console.ReadKey();

运行截图如下:

原文地址:https://www.cnblogs.com/527289276qq/p/4575520.html