regexp.html 828 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. <script>
  9. const str = "1336661357"
  10. const tel = /[0-9]{11}/
  11. var b = tel.test( tel );
  12. //console.log( b )
  13. /**
  14. * . 匹配所有
  15. * * 零位或者多为
  16. * + 一次以上
  17. * [] 范围匹配
  18. * () 子匹配
  19. * ^ 以某某开头
  20. * $ 以某某结尾
  21. * ? 可有可没有 懒汉模式
  22. * {} 匹配次数
  23. */
  24. const strEmail = "admin@80boys.com"
  25. const email = /\w{3,20}@\w{3,20}\.\w{3,20}/
  26. console.log( email.test( strEmail ) )
  27. const emailreg = new RegExp("\\w{3,20}@\\w{3,20}\\.\\w{3,20}")
  28. console.log( emailreg.test( strEmail ) )
  29. </script>
  30. </body>
  31. </html>