zheng 2 horas atrás
pai
commit
71c083a379
3 arquivos alterados com 49 adições e 7 exclusões
  1. 10 7
      15.正则/5.字符类.html
  2. 20 0
      15.正则/6.分组.html
  3. 19 0
      15.正则/7.案例.html

+ 10 - 7
15.正则/5.字符类.html

@@ -38,13 +38,16 @@
         // console.log(reg6.test('1'));
         // console.log(reg6.test(' '));
 
-        const reg7 = /\S/;
-        console.log(reg7.test('C'));
-        console.log(reg7.test('1'));
-        console.log(reg7.test(' '));
-        console.log(reg7.test('\n'));
-        console.log(reg7.test('\r'));
-        console.log(reg7.test('\t'));
+        // const reg7 = /\S/;
+        // console.log(reg7.test('C'));
+        // console.log(reg7.test('1'));
+        // console.log(reg7.test(' '));
+        // console.log(reg7.test('\n'));
+        // console.log(reg7.test('\r'));
+        // console.log(reg7.test('\t'));
+
+        const reg8 = /^[^a-z]/;
+        console.log(reg8.test('C'));
     </script>
 </body>
 

+ 20 - 0
15.正则/6.分组.html

@@ -0,0 +1,20 @@
+<!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)/;
+        const str = '2026-11-29';
+        // 11/29/2026
+        const reg1 = /^(\d{4})-(\d{2})-(\d{2})$/
+        console.log(str.replace(reg1, '$2/$3/$1'))
+    </script>
+</body>
+
+</html>

+ 19 - 0
15.正则/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>