12345678910111213141516171819202122232425262728 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 1.手机号脱敏 13748576543 => 137****6543
- // const str = '13748576543';
- // const reg = /^(1[3-9]\d)\d{4}(\d{4})$/;
- // console.log(str.replace(reg,'$1****$2'))
- // 2.密码匹配 (6-16字母,数字,下划线)
- // const reg = /^\w{6,16}$/
- // // const reg = /^[a-zA-Z0-9_]{6,16}$/
- // console.log(reg.test("hello12345"))
- // 3.匹配16进制颜色
- // const reg = /^#([0-9a-fA-F]{6})|([0-9a-fA-F]{3})$/
- // console.log(reg.test("#ff0000"))
- // console.log(reg.test("#ff0"))
- // 匹配24小时时间 23:59
- </script>
- </body>
- </html>
|