> string filepath = @"\folder\aaa.bb"; > //string filepath = @"\aaa.bb"; // fails > > string pat = @"\\(?:.+)\\(.+)\.(.+)"; > > > > > var m = Regex.Match(filepath, pat); > > if (m.Success) > { > Console.WriteLine("{0}", m.Groups[1].Captures[0].ToString()); > Console.WriteLine("{0}", m.Groups[2].Captures[0].ToString()); > } > else > Console.WriteLine("No match"); > > > Console.ReadLine();OK, thanks everyone for their input.