fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var regex = new Regex(@"^[A-Z][^\sA-Z]*[A-Z][^\sA-Z]*[A-Z]");
  9. string[] strings = {"XYZName", "X.YZName", "XY-ZName"};
  10.  
  11. foreach (String s in strings)
  12. {
  13. var m = regex.Match(s);
  14. if (m.Success) {
  15. Console.WriteLine(Regex.Replace(m.Value, @"[^A-Z]+", ""));
  16. }
  17. }
  18. }
  19. }
Success #stdin #stdout 0.05s 29540KB
stdin
Standard input is empty
stdout
XYZ
XYZ
XYZ