12345678910111213141516171819202122232425262728293031323334353637 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <script>
- const str = "1336661357"
- const tel = /[0-9]{11}/
- var b = tel.test( tel );
- //console.log( b )
- /**
- * . 匹配所有
- * * 零位或者多为
- * + 一次以上
- * [] 范围匹配
- * () 子匹配
- * ^ 以某某开头
- * $ 以某某结尾
- * ? 可有可没有 懒汉模式
- * {} 匹配次数
- */
- const strEmail = "admin@80boys.com"
- const email = /\w{3,20}@\w{3,20}\.\w{3,20}/
- console.log( email.test( strEmail ) )
- const emailreg = new RegExp("\\w{3,20}@\\w{3,20}\\.\\w{3,20}")
- console.log( emailreg.test( strEmail ) )
- </script>
- </body>
- </html>
|