fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var strs = new List<string> { "abc", "ab .c", "ab123,cd2, ,,%&$§56"};
  12. foreach (var input in strs) {
  13. var output = Regex.Matches(input, @"[\p{L}\p{N}]+").Cast<Match>().Select(x => x.Value);
  14. Console.WriteLine($"--- Checking {input} ---");
  15. Console.WriteLine(string.Join("; ", output));
  16. }
  17. }
  18. }
Success #stdin #stdout 0.05s 22204KB
stdin
Standard input is empty
stdout
--- Checking abc ---
abc
--- Checking ab .c ---
ab; c
--- Checking ab123,cd2,  ,,%&$§56 ---
ab123; cd2; 56