fork download
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var s = "Match word but not word1, w1ord or word!";
  11. var res_linq = s.Split().Where(x => x.All(c => (c >= 65 && c <= 90) || c >=97 && c<= 122));
  12. Console.WriteLine(string.Join(";", res_linq));
  13. // REGEX
  14. var res_regex = Regex.Matches(s, @"(?<!\S)[a-zA-Z]+(?!\S)").Cast<Match>().Select(m=>m.Value);
  15. Console.WriteLine(string.Join(";", res_regex));
  16. }
  17. }
Success #stdin #stdout 0.03s 30256KB
stdin
Standard input is empty
stdout
Match;word;but;not;or
Match;word;but;not;or