fork download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6.  
  7. public class Test
  8. {
  9.  
  10. public static void Main()
  11. {
  12. string test = "test...abc...";
  13. string leftTrimmed = test.TrimLettersLeft();
  14. Console.WriteLine(test);
  15. Console.WriteLine(leftTrimmed);
  16. }
  17. }
  18.  
  19. static class Exension
  20. {
  21. public static string TrimLettersLeft(this string input)
  22. {
  23. int lastLetterIndex = -1;
  24. for (int i = input.Length - 1; i >= 0; i--)
  25. {
  26. if (Char.IsLetter(input[i]))
  27. {
  28. lastLetterIndex = i;
  29. break;
  30. }
  31. }
  32.  
  33. if (lastLetterIndex == -1)
  34. return input;
  35. else
  36. return input.Substring(0, lastLetterIndex + 1);
  37. }
  38. }
Success #stdin #stdout 0.02s 33824KB
stdin
Standard input is empty
stdout
test...abc...
test...abc