fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7.  
  8. public static void Main()
  9. {
  10. string A = "1 2 3A 4 5C 6 ABCD EFGH 7 8D 9";
  11. string[] words = A.Split();
  12. string result = string.Join(" ",
  13. words.Select(w => w.Any(c => Char.IsDigit(c)) ?
  14. new string(w.Where(c => Char.IsDigit(c)).ToArray()) : w)
  15. .ToArray());
  16. Console.Write(result);
  17. }
  18. }
Success #stdin #stdout 0.04s 37016KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 ABCD EFGH 7 8 9