且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拆分具有空格的字符串,除非将空格括在“引号”中?

更新时间:2023-01-14 21:18:12

string input = "one \"two two\" three \"four four\" five six";
var parts = Regex.Matches(input, @"[\""].+?[\""]|[^ ]+")
                .Cast<Match>()
                .Select(m => m.Value)
                .ToList();