Reg.cs 810 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections.Generic;
  2. using System.Text.RegularExpressions;
  3. namespace DaJiaoYan.Utils
  4. {
  5. public static class Reg
  6. {
  7. public const string NUMBER = "\\d";
  8. public enum Type
  9. {
  10. Number
  11. }
  12. private static readonly Dictionary<Type, string> map = new Dictionary<Type, string>()
  13. {
  14. { Type.Number, NUMBER },
  15. };
  16. public static bool Match(string s, Type t, RegexOptions options = RegexOptions.IgnoreCase)
  17. {
  18. var m = Regex.Match(s, map[t], options);
  19. return m.Success;
  20. }
  21. public static bool Match(string s, string t, RegexOptions options = RegexOptions.IgnoreCase)
  22. {
  23. var m = Regex.Match(s, t, options);
  24. return m.Success;
  25. }
  26. }
  27. }