0

我有以下格式的字符串:

httP;//whatvere[CanIncludeSpaces"].url -a -b -c

如何在字符串数组中获取参数 -a、-b、-c?

谢谢

4

1 回答 1

1

这是我想出的:

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'
于 2012-10-01T23:06:03.490 回答