1.正则.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <!-- 正则表达式
  10. const 名称 = /需要校验的规则/
  11. 修饰符:
  12. g 匹配全局
  13. i 不区分大小写
  14. -->
  15. <script>
  16. const reg = /aa/gi;
  17. const str = 'AA,四大名著有aa,我也爱看Aa'
  18. console.log(reg.test('xxxxxx'));
  19. console.log(reg.exec(str));
  20. console.log(str.match(reg))
  21. const res = str.replace(reg, '红楼梦');
  22. console.log(res);
  23. /**
  24. * js数据类型
  25. * 基本:string boolean number undefined null symbol bigInt
  26. * 引用:Object(对象 数组 函数)
  27. * 怎么去判断数据类型
  28. * typeof
  29. * instanceof
  30. * Object.prototype.toString.call()
  31. * constructor
  32. * 盒模型
  33. * 数组的方法 那些会改变原数组 那些不会改变原数组
  34. * for in / for of
  35. * /
  36. </script>
  37. </body>
  38. </html>