0
我是.NET新手,很難理解Regex
對象。在.NET中使用命名組正則表達式
我想要做的是以下。這是僞代碼;我不知道使這項工作的實際代碼如下:
string pattern = ...; // has multiple groups using the Regex syntax <groupName>
if (new Regex(pattern).Apply(inputString).HasMatches)
{
var matches = new Regex(pattern).Apply(inputString).Matches;
return new DecomposedUrl()
{
Scheme = matches["scheme"].Value,
Address = matches["address"].Value,
Port = Int.Parse(matches["address"].Value),
Path = matches["path"].Value,
};
}
我需要更改以使此代碼有效嗎?