zheng 10 ore în urmă
părinte
comite
f15ad442e3

+ 1 - 1
18.正则/4.量词.html

@@ -20,7 +20,7 @@
         // console.log(reg.test(' '));
         // console.log(reg.test('aab'));
 
-        // ? 1次或多次
+        // + 1次或多次
         // const reg = /a+$/;
         // console.log(reg.test('aa'));
         // console.log(reg.test(' '));

+ 35 - 0
18.正则/5.字符类.html

@@ -0,0 +1,35 @@
+<!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>
+        // const reg = /[abc]/;
+        // console.log(reg.test("ababab"));
+        // console.log(reg.test("abc"));
+        // console.log(reg.test("acbac"));
+        // console.log(reg.test("dh"));
+        // console.log(reg.test("abbhj"));
+
+        // const reg1 = /[0-9]/;
+        // const reg2 = /[a-z]/;
+        // const reg3 = /[A-Z]/;
+        const reg4 = /\w/;
+        // console.log(reg1.test(7));
+
+        // const reg5 = /^[^a-z]/;
+        // console.log(reg5.test(990));
+
+        const reg5 = /./;
+        console.log(reg5.test('\n'));
+        console.log(reg5.test('\r'));
+        console.log(reg5.test('\t'));
+        console.log(reg5.test(' '));
+        console.log(reg5.test('1212'));
+
+    </script>
+</body>
+</html>

+ 29 - 0
18.正则/6.分组.html

@@ -0,0 +1,29 @@
+<!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>
+        const reg = /(ab)(cd)/;
+        console.log(reg.test("abcd"));
+        const str = '2026-05-17';
+        const reg1 = /^(\d{4})-(\d{2})-(\d{2})$/;
+        // $1 $2 $3
+        // 05/17/2026
+        console.log(str.replace(reg1,'$2/$3/$1'))
+        // /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/
+        // 逻辑运算符:| 分支 或
+        const reg2 = /a|b/;
+        console.log(reg2.test("a"));
+        console.log(reg2.test("ab"));
+        console.log(reg2.test("b"));
+        console.log(reg2.test("ac"));
+        console.log(reg2.test("d"));
+        console.log(reg2.test("fa"));
+        // https://regexper.com/
+    </script>
+</body>
+</html>

+ 19 - 0
18.正则/7.案例.html

@@ -0,0 +1,19 @@
+<!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.手机号脱敏 13789430987 => 137****0987
+
+        // 2.密码匹配 (6-16字母、数字、下划线)
+
+        // 3.匹配16进制颜色 #ff0000 #0f0
+
+        // 4.匹配24小时时间 23:59 20:12 08:35 18:22
+    </script>
+</body>
+</html>

BIN
18.正则/元字符.jpg