c#正则匹配两个字符之间的内容

字符串是"exportTXT\20161115\11.15 AAA 11111(7777).txt"
我想取得的内容是"11.15 AAA 11111(7777)"
也就是说取得第二个 \和.txt中间的内容,正则应该怎么写呀谢谢了
最新回答
我丑故我知

2024-05-09 07:19:12

        static void Main(string[] args)
        {
            string s = @"exportTXT\20161115\11.15 AAA 11111(7777).txt";
            Regex r = new Regex(@"\\.+?\\(.+)\.txt");
            string s1 = r.Match(s).Groups[1].Value;
            Console.WriteLine(s1);
            Console.ReadLine();
        }
颓废美堕落情

2024-05-09 19:16:04

@"[^\\]+(?=\.txt)"