reg.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // 效验电话
  2. export const phoneReg = /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/;
  3. // 效验qq
  4. export const qqReg = /^[1-9][0-9]{4,10}$/;
  5. // 效验微信号
  6. export const wechatReg = /^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/;
  7. // 效验邮箱
  8. export const emailReg = /^([A-Za-z0-9_\-.])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,4})$/;
  9. // 效验手机号码
  10. export const mobileReg = /^1\d{10}$/;
  11. // 短信验证码
  12. export const smsCodeReg = /^\d{6}$/;
  13. // 密码
  14. export const passwordReg = /^(?=.*\d)(?=.*[a-zA-Z]).{6,16}$/;
  15. // 效验身份证
  16. export const idCardReg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  17. // 效验url
  18. export const urlReg = /^((https?|ftp|file):\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
  19. // 效验Ipv4
  20. export const ipv4Reg = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
  21. // 效验十六进制颜色正则
  22. export const rgbReg = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
  23. // 只能输入字母、下划线,且字母开头结尾,不能__两个下划线相连
  24. export const letterAndUnderlineReg = /^[A-Za-z]([A-Za-z]|_[A-Za-z])*$/;
  25. // 正整数
  26. export const positiveIntegerReg = /^[1-9]\d*$/;
  27. // 整数
  28. export const integerReg = /^-?[1-9]\d*$/;
  29. // 数字
  30. export const numberReg = /^(-?\d+)(\.\d*)?$/;
  31. // 中文姓名
  32. export const chineseNameReg = /^[\u4e00-\u9fa5]+[·-]?[\u4e00-\u9fa5]+$/;
  33. // md5
  34. export const md5Reg = /^[a-f\d]{32}|[A-F\d]{32}$/;
  35. // 公司名称
  36. export const companyNameReg = /^[\u4e00-\u9fa5()()\da-zA-Z&]{2,}$/;
  37. // 二级域名
  38. export const subdomainReg = /^[a-z0-9-]{4,20}$/;