Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

C#通过正则表达式提取https://vo1.123188kk.com/20230727/JvvztLv1/hls/key.key中的key.key

  1. User
  2. Assistant

    可以使用正则表达式来提取该网址中的key.key,代码示例如下:

    using System;
    using System.Text.RegularExpressions;
    
    class Program
    {
        static void Main()
        {
            string url = "https://vo1.123188kk.com/20230727/JvvztLv1/hls/key.key";
    
            string pattern = @"\/([^\/]+)$"; // 匹配最后一个斜杠后的内容
    
            Match match = Regex.Match(url, pattern);
    
            if (match.Success)
            {
                string key = match.Groups[1].Value;
                Console.WriteLine(key); // 输出key.key
            }
            else
            {
                Console.WriteLine("匹配失败");
            }
        }
    }
    

    运行结果为:

    key.key
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.