From a8829f76c6d6448942dc28ec52c50a6bf78b6370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E5=88=A9=E7=BE=A4?= <2246026162@qq.com> Date: Tue, 15 Nov 2022 23:52:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-11-14\346\255\243\345\210\231.html" | 25 +++++++++ .../2022-11-14\346\255\243\345\210\231.md" | 51 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 "32\351\231\206\345\210\251\347\276\244/\344\275\234\344\270\232/2022-11-14\346\255\243\345\210\231.html" create mode 100644 "32\351\231\206\345\210\251\347\276\244/\347\254\224\350\256\260/2022-11-14\346\255\243\345\210\231.md" diff --git "a/32\351\231\206\345\210\251\347\276\244/\344\275\234\344\270\232/2022-11-14\346\255\243\345\210\231.html" "b/32\351\231\206\345\210\251\347\276\244/\344\275\234\344\270\232/2022-11-14\346\255\243\345\210\231.html" new file mode 100644 index 0000000..c2c578c --- /dev/null +++ "b/32\351\231\206\345\210\251\347\276\244/\344\275\234\344\270\232/2022-11-14\346\255\243\345\210\231.html" @@ -0,0 +1,25 @@ + + + + + + + Document + + + + + + \ No newline at end of file diff --git "a/32\351\231\206\345\210\251\347\276\244/\347\254\224\350\256\260/2022-11-14\346\255\243\345\210\231.md" "b/32\351\231\206\345\210\251\347\276\244/\347\254\224\350\256\260/2022-11-14\346\255\243\345\210\231.md" new file mode 100644 index 0000000..be37b6d --- /dev/null +++ "b/32\351\231\206\345\210\251\347\276\244/\347\254\224\350\256\260/2022-11-14\346\255\243\345\210\231.md" @@ -0,0 +1,51 @@ +### 正则 + +###### 创建正则 + +``` +var exp = /a/ +console.log(exp.test('a')) +或者 +console.log(/a/.test('a')) +或 +console.log(/a/.exec('a')) +匹配到true 没匹配到false +``` + +###### 匹配 + +1.数字:[0-9] 简写:\d + +``` +console.log(/[0-9]/.exec('3783630')) +console.log(/\d/.exec('3783630')) +``` + +2.字母:[a-zA-Z] 简写:\w + +``` +console.log(/[a-z]/.exec('ugdvj')) +``` + +3.(1){m,n}匹配最少m次,最多n次 + +​ {m}匹配m次 + +​ {m,}最少匹配m次,到无限次 + +``` +//匹配数字4到6个 +console.log(/\d{4,6}/.exec('37830')) +``` + +4. + +​ 贪婪模式:? + +​ {1,} :匹配1次或多次 简写:+ + +​ {0,}:匹配0次或多次 简写:* + +​ {0,1}:匹配0次或1次 简写:? + +​ \ No newline at end of file -- Gitee