StringHelper.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace DTHelperStd
  10. {
  11. public static class StringHelper
  12. {
  13. public static string CleanSpecialCharacters(string s)
  14. {
  15. return new StringBuilder(s)
  16. .Replace("+", "")
  17. .Replace("-", "")
  18. .Replace("$", "")
  19. .Replace("/", "")
  20. .Replace(".", "")
  21. .Replace("£", "")
  22. .ToString();
  23. }
  24. //maybe move to helper class
  25. public static int CountWords(string s)
  26. {
  27. return s.Split().Length;
  28. }
  29. public static string GetSQLiteColumnName(int pos)
  30. {
  31. return "Col_" + pos;
  32. }
  33. public static bool IsLetterOnly(string data)
  34. {
  35. if (data.Length == 0)
  36. return false;
  37. for (var i = 0; i < data.Length; i++)
  38. {
  39. if (((data[i] < 'a' || data[i] > 'z') && (data[i] < 'A' || data[i] > 'Z')) && data[i] != ' ')
  40. return false;
  41. }
  42. return true;
  43. }
  44. }
  45. }