低调的感觉 2019-04-15 11:25 采纳率: 100%
浏览 338
已采纳

C# 将一个内容里所有相关的字符串转为6位小数

[[[110.99427773597672,33.250843226213867],[111.17966395737562,33.114741248227936],[111.28837257603199,32.859940786884621]]]

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-04-15 11:52
    关注
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    
    namespace Q756847
    {
        class Program
        {
            static void Main(string[] args)
            {
                string s = "[[[110.99427773597672,33.250843226213867],[111.17966395737562,33.114741248227936],[111.28837257603199,32.859940786884621]]]";
                var result = Regex.Matches(s, @"\d{1,3}\.\d{6}").Cast<Match>().Select(x => x.Value);
                foreach (var item in result)
                    Console.WriteLine(item);
            }
        }
    }
    
    

    110.994277
    33.250843
    111.179663
    33.114741
    111.288372
    32.859940
    Press any key to continue . . .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?