C# 从Twitch剪辑URL提取Id
如何提取Twitch剪辑URL的Id 例如:C# 从Twitch剪辑URL提取Id,c#,.net,regex,C#,.net,Regex,如何提取Twitch剪辑URL的Id 例如: https://clips.twitch.tv/KindYummyCarrotPeteZaroll?some=1 我只需要Id部分,例如:https://clips.twitch.tv/[ID]?v=1 上面示例中的Id是KindYummyCarrotPeteZaroll。应忽略后面的任何查询字符串,而不是Id的一部分 我试过: MatchCollection matches = Regex.Matches(url, @"^(https://cli
https://clips.twitch.tv/KindYummyCarrotPeteZaroll?some=1
我只需要Id部分,例如:https://clips.twitch.tv/[ID]?v=1
上面示例中的Id是KindYummyCarrotPeteZaroll。应忽略后面的任何查询字符串,而不是Id的一部分
我试过:
MatchCollection matches = Regex.Matches(url, @"^(https://clips\.twitch\.tv/)(?:(?!http).)*?");
但我无法在一组中捕获Id。我正在使用ASP.NET和C.不需要正则表达式:
string str = "https://clips.twitch.tv/KindYummyCarrotPeteZaroll?some=1";
string id = str.Split('/', '?')[3];
尝试