fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] strings = { "File name without 3 digit end.jpg",
  9. " Test",
  10. " Test (1)",
  11. " Test (1) (2)",
  12. " Test (123) (232)"};
  13.  
  14. foreach (String s in strings)
  15. {
  16. Console.WriteLine(Regex.Replace(s, @"^(.*) \(\d+\)", "$1"));
  17. }
  18. }
  19. }
Success #stdin #stdout 0.03s 134592KB
stdin
Standard input is empty
stdout
File name without 3 digit end.jpg
 Test
 Test
 Test (1)
 Test (123)