fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var texts = new List<string> { "Shell", "ShellView", "Console", "ConsoleView" };
  11. var rx = new Regex(@"^(\w+?)(View)?$");
  12. foreach (var text in texts)
  13. {
  14. var match = rx.Match(text)?.Groups[1].Value;
  15. Console.WriteLine(match);
  16. }
  17. }
  18. }
Success #stdin #stdout 0.08s 25536KB
stdin
Standard input is empty
stdout
Shell
Shell
Console
Console