gray 发表于 2013-2-4 19:25:13

使用正则表达式取正确的货币值

使用C#的正则表达式取正确的货币值

代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace 正则表达式
{
    class Program
    {
      static void Main(string[] args)
      {
            string temp = "$-132,131,313.132";
            temp = Regex.Replace(temp, @"[^0-9.-]", "");
            Console.ReadLine();
      }
    }
}

得到的结果是:-132131313.132
页: [1]
查看完整版本: 使用正则表达式取正确的货币值