Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Twitch剪辑URL提取Id_C#_.net_Regex - Fatal编程技术网

C# 从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

如何提取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://clips\.twitch\.tv/)(?:(?!http).)*?");
但我无法在一组中捕获Id。我正在使用ASP.NET和C.

不需要正则表达式:

string str = "https://clips.twitch.tv/KindYummyCarrotPeteZaroll?some=1";
string id = str.Split('/', '?')[3];
尝试