UserUtil.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Text.RegularExpressions;
  2. namespace SC.XR.Unity.Module_PlatformAccount
  3. {
  4. public enum AccountType
  5. {
  6. NotAccount,
  7. Phone,
  8. Email
  9. }
  10. public class UserUtil
  11. {
  12. public static string RegionCode(string account)
  13. {
  14. switch (PhoneOrEmail(account))
  15. {
  16. case AccountType.NotAccount:
  17. break;
  18. case AccountType.Phone:
  19. return RegexConfig.except_regionCode.Match(account).ToString();
  20. case AccountType.Email:
  21. return account;
  22. }
  23. return "";
  24. }
  25. public static AccountType PhoneOrEmail(string account)
  26. {
  27. if (RegexConfig.format_phone.IsMatch(account))
  28. {
  29. return AccountType.Phone;
  30. }
  31. else if(RegexConfig.format_email.IsMatch(account))
  32. {
  33. return AccountType.Email;
  34. }
  35. return AccountType.NotAccount;
  36. }
  37. public static bool AccountFormat(string account)
  38. {
  39. if (RegexConfig.format_bindingPhone.IsMatch(account)
  40. ||RegexConfig.format_email.IsMatch(account))
  41. {
  42. return true;
  43. }
  44. return false;
  45. }
  46. public static bool PasswordFormat(string password)
  47. {
  48. if (RegexConfig.format_password.IsMatch(password) && !RegexConfig.format_pinyin.IsMatch(password))
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. }
  55. }