|
|
@@ -0,0 +1,22 @@
|
|
|
+<!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 名称 = /需要校验的规则/
|
|
|
+ // test 匹配文本中是否包含要校验的字符 返回布尔值
|
|
|
+ // replace 替换指定字符
|
|
|
+ const reg = /西游记/g;
|
|
|
+ const str = '西游记是四大名著,西游记';
|
|
|
+ console.log(reg.test("红楼梦是四大名著"));
|
|
|
+ console.log(reg.exec(str),'exec');
|
|
|
+ console.log(str.replace(reg,'水浒传'));
|
|
|
+ console.log(str.match(reg),'match')
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|