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); }