C#获取字符串中的数目字

C#获取字符串中的数字 using System.Text.RegularExpressions/// summary/// 获取字符串中的数字/// /

C#获取字符串中的数字
 using System.Text.RegularExpressions;

/// <summary>
        /// 获取字符串中的数字
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns>数字</returns>
        public static decimal GetNumber(string str)
        {
            decimal result = 0;
            if (str != null && str != string.Empty)
            {
                // 正则表达式剔除非数字字符(不包含小数点.)
                str = Regex.Replace(str, @"[^\d.\d]", "");

                // 如果是数字,则转换为decimal类型
                if (Regex.IsMatch(str, @"^[+-]?\d*[.]?\d*$"))
                {
                    result = decimal.Parse(str);
                }
            }
            return result;
        }
[最优解释]

[其他解释]
请问你这个是问题还是分享答案?
[其他解释]
哦,原来是在倒分。