我现在的数字:
113:21:57.56086E
我想转成
113.2157.56086E我现在用下面这个正则,结果就有了两个小数点,如何能把后面一个取消掉呢?
string s = "23:07:33.09156N,113:21:57.56086E";
            string strResult = Regex.Replace(s, @"(?<Degree>\d{2,3}):(?<Minute>\d{2}):(?<Second>[\.\d]{1,8})(?<ID>[NEWSnews]?)",
                             @"$1.$2$3$4");
            if (strResult == null)
            {
                return;
            }
            MessageBox.Show(strResult);

解决方案 »

  1.   

    找到匹配后用IndexOf把第二个替换吧
      

  2.   

    我现在的数字:
    113:21:57.56086E
    我想转成
    113.2157.56086E这个没问题,我不是想要这个。想把第二个去掉。变成:
    113.215756086E
      

  3.   

    已经用这样方式实现了。不过还是感觉太垃圾了方法。希望得到更好的方法。学习学习strText = Regex.Replace(strText,
                                @"(?<Degree>\d{2,3}):(?<Minute>\d{2}):(?<Second>[\d]{1,2})(?<Second2>[\.\d]{0,6})(?<ID>[NEWSnews]?)",
                                @"$1.$2$3$5");
      

  4.   

    string s = "23:07:33.09156N,113:21:57.56086E";
    s=s.Replace(".","");//看那点多余 先去了不就OK了
    s=Regex.Replace(s,@"(\d+):(\d+):([\d.]+)[A-Z]","$1.$2$3");