diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/01-PPT/web APIs06.pdf" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/01-PPT/web APIs06.pdf" new file mode 100644 index 0000000000000000000000000000000000000000..f28287c053973f0555b0c56a9f623f3daa7cba36 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/01-PPT/web APIs06.pdf" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/README.md" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/README.md" new file mode 100644 index 0000000000000000000000000000000000000000..7752f5d6e645fda3aa05da1047544afbd768ab88 --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/README.md" @@ -0,0 +1,283 @@ +# Web APIs - 第6天笔记 + +> 目标:能够利用正则表达式完成小兔鲜注册页面的表单验证,具备常见的表单验证能力 + +- 正则表达式 +- 综合案例 +- 阶段案例 + + +## 正则表达式 + +**正则表达式**(Regular Expression)是一种字符串匹配的模式(规则) + +**使用场景:** + +- 例如验证表单:手机号表单要求用户只能输入11位的数字 (匹配) +- 过滤掉页面内容中的一些敏感词(替换),或从字符串中获取我们想要的特定部分(提取)等 + + ![67607966636](assets/1676079666366.png) + + + + + +### 正则基本使用 + +1. 定义规则 + + ~~~JavaScript + const reg = /表达式/ + ~~~ + + - 其中` / / `是正则表达式字面量 + - 正则表达式也是`对象 ` + +2. 使用正则 + + - `test()方法` 用来查看正则表达式与指定的字符串是否匹配 + - 如果正则表达式与指定的字符串匹配 ,返回`true`,否则`false` + +~~~html + + + +~~~ + +### 元字符 + +1. **普通字符:** + +- 大多数的字符仅能够描述它们本身,这些字符称作普通字符,例如所有的字母和数字。 +- 普通字符只能够匹配字符串中与它们相同的字符。 +- 比如,规定用户只能输入英文26个英文字母,普通字符的话 /[abcdefghijklmnopqrstuvwxyz]/ + +2. **元字符(特殊字符)** + +- 是一些具有特殊含义的字符,可以极大提高了灵活性和强大的匹配功能。 +- 比如,规定用户只能输入英文26个英文字母,换成元字符写法: /[a-z]/ + +#### 边界符 + +正则表达式中的边界符(位置符)用来提示字符所处的位置,主要有两个字符 + +![67608008165](assets/1676080081650.png) + +>如果 ^ 和 $ 在一起,表示必须是精确匹配 + +~~~html + + + +~~~ + +#### 量词 + +量词用来设定某个模式重复次数 + +![67608018538](assets/1676080185383.png) + +> 注意: 逗号左右两侧千万不要出现空格 + +~~~html + + +~~~ + +#### 范围 + +表示字符的范围,定义的规则限定在某个范围,比如只能是英文字母,或者数字等等,用表示范围 + + ![67608029616](assets/1676080296168.png) + +~~~html + + + +~~~ + +#### 字符类 + +某些常见模式的简写方式,区分字母和数字 + +![67608035363](assets/1676080353637.png) + + ![67608037232](assets/1676080372325.png) + +## 替换和修饰符 + +replace 替换方法,可以完成字符的替换 + + ![67608043716](assets/1676080437160.png) + +~~~html + + + +~~~ + +修饰符约束正则执行的某些细节行为,如是否区分大小写、是否支持多行匹配等 + +- i 是单词 ignore 的缩写,正则匹配时字母不区分大小写 +- g 是单词 global 的缩写,匹配所有满足正则表达式的结果 + +~~~html + + + +~~~ + +## 正则插件 + + ![67608054863](assets/1676080548639.png) + + + +## change 事件 + +给input注册 change 事件,值被修改并且失去焦点后触发 + +## 判断是否有类 + + ![67608061879](assets/1676080618794.png) + +元素.classList.contains() 看看有没有包含某个类,如果有则返回true,么有则返回false + + + diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676079666366.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676079666366.png" new file mode 100644 index 0000000000000000000000000000000000000000..71ebf5f5d7ec1cfd9a686394e50dac0b38d20218 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676079666366.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080081650.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080081650.png" new file mode 100644 index 0000000000000000000000000000000000000000..ba9ba5c0c7eee85bc0e246cd544e4f2a371cf28a Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080081650.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080185383.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080185383.png" new file mode 100644 index 0000000000000000000000000000000000000000..4978a900fc1752110abcd424048df97d0ee07751 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080185383.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080296168.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080296168.png" new file mode 100644 index 0000000000000000000000000000000000000000..a603c5bcc06d717d349177e6a4834138b69a9b1f Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080296168.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080353637.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080353637.png" new file mode 100644 index 0000000000000000000000000000000000000000..7980129e036a26b57936d447fc37552fa1427883 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080353637.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080372325.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080372325.png" new file mode 100644 index 0000000000000000000000000000000000000000..5b51c29d7f5fb422099a551fa7947e7bc1178f0e Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080372325.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080437160.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080437160.png" new file mode 100644 index 0000000000000000000000000000000000000000..885a9e3e3440b3ce5ab5bf66a4b05924584fd369 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080437160.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080548639.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080548639.png" new file mode 100644 index 0000000000000000000000000000000000000000..79879b92aa6225569e22c9766849fc2c51b85714 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080548639.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080618794.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080618794.png" new file mode 100644 index 0000000000000000000000000000000000000000..c8c5a84de997126ed09c9075e944ad27af0eb1b1 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/02-\347\254\224\350\256\260/assets/1676080618794.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/01-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\232\204\344\275\277\347\224\250.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/01-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\232\204\344\275\277\347\224\250.html" new file mode 100644 index 0000000000000000000000000000000000000000..8c576abdf74832f96b9425f20b9faf286570808d --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/01-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\232\204\344\275\277\347\224\250.html" @@ -0,0 +1,35 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/02-\345\205\203\345\255\227\347\254\246.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/02-\345\205\203\345\255\227\347\254\246.html" new file mode 100644 index 0000000000000000000000000000000000000000..a77f6079311c2016094053a590a2642ab05644ce --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/02-\345\205\203\345\255\227\347\254\246.html" @@ -0,0 +1,204 @@ + + + + + + + + Document + + + + + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/03-\351\252\214\350\257\201\347\224\250\346\210\267\345\220\215\346\241\210\344\276\213.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/03-\351\252\214\350\257\201\347\224\250\346\210\267\345\220\215\346\241\210\344\276\213.html" new file mode 100644 index 0000000000000000000000000000000000000000..2d288b0b155f73da96eef74b64ff3a59dadb5c5e --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/03-\351\252\214\350\257\201\347\224\250\346\210\267\345\220\215\346\241\210\344\276\213.html" @@ -0,0 +1,59 @@ + + + + + + + + Document + + + + + + 提示 + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/04-\346\255\243\345\210\231\344\277\256\351\245\260\347\254\246.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/04-\346\255\243\345\210\231\344\277\256\351\245\260\347\254\246.html" new file mode 100644 index 0000000000000000000000000000000000000000..b00b7f407e0f67d990182d3be2a85609d391994e --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/04-\346\255\243\345\210\231\344\277\256\351\245\260\347\254\246.html" @@ -0,0 +1,51 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/05-\350\277\207\346\273\244\346\225\217\346\204\237\350\257\215.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/05-\350\277\207\346\273\244\346\225\217\346\204\237\350\257\215.html" new file mode 100644 index 0000000000000000000000000000000000000000..664abd99c0487cb56d11a7dd26a3e6c00561831f --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/05-\350\277\207\346\273\244\346\225\217\346\204\237\350\257\215.html" @@ -0,0 +1,41 @@ + + + + + + + + Document + + + + + +
+ + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/06-change\344\272\213\344\273\266.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/06-change\344\272\213\344\273\266.html" new file mode 100644 index 0000000000000000000000000000000000000000..3f1959af873abf5a9150ca0972d72b6655c4b7b3 --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/06-change\344\272\213\344\273\266.html" @@ -0,0 +1,23 @@ + + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/09-\346\217\220\345\217\226.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/09-\346\217\220\345\217\226.html" new file mode 100644 index 0000000000000000000000000000000000000000..ec723db930eadfb3c248bc4b83338ed8632d147d --- /dev/null +++ "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/09-\346\217\220\345\217\226.html" @@ -0,0 +1,23 @@ + + + + + + + Document + + + + 张三儿的电话是13005976666,他给女朋友打电话,她电话是18605978888, + 可是她正在给她的男朋友打电话,他的电话是13305915555,告诉他张三的银行卡号是:32456987421` + + + + \ No newline at end of file diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error.png" new file mode 100644 index 0000000000000000000000000000000000000000..c9867ebd498f268574677997b13a6292b0cae93f Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error1.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error1.png" new file mode 100644 index 0000000000000000000000000000000000000000..07e9befe7df09cadea8aba64ca51ae566f4accc3 Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/error1.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/right.png" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/right.png" new file mode 100644 index 0000000000000000000000000000000000000000..2d68690d1e579a538a42971628d9a90502d8d41e Binary files /dev/null and "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/04-code/images/right.png" differ diff --git "a/\345\217\266\344\277\212\346\235\260/20241128 \346\255\243\345\210\231\350\241\250\350\276\276/register.html" "b/\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/register.html" similarity index 100% rename from "\345\217\266\344\277\212\346\235\260/20241128 \346\255\243\345\210\231\350\241\250\350\276\276/register.html" rename to "\345\217\266\344\277\212\346\235\260/20241201 \347\273\274\345\220\210\347\273\203\344\271\240/register.html"