Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用如下文件名列表:
我们如何检查文件名是否以模式 (n).extension 结尾?如果是这样,如何只获取没有 (n) 部分的文件名?
这似乎有效
void Main() { string test = "file(321).pdf"; string pattern = @"\([0-9]+\)\."; bool m = Regex.IsMatch(test, pattern); if(m == true) test = Regex.Replace(test, pattern, "."); Console.WriteLine(test); }