我有以下格式的字符串:
httP;//whatvere[CanIncludeSpaces"].url -a -b -c
如何在字符串数组中获取参数 -a、-b、-c?
谢谢
这是我想出的:
var str = "httP;//whatvere[CanIncludeSpaces\"].url -a -b -c";
var endOfUrl = str.LastIndexOf(".url") + 4;
var args = str.Substring(endOfUrl).Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
//args is ["-a", "-b", "-c"]
//also, the URL is easy to get:
var url = str.Substring(0, endOfUrl);
//url is now 'httP;//whatvere[CanIncludeSpaces"].url'