|
@@ -0,0 +1,39 @@
|
|
|
+<!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 = /[abc]/;
|
|
|
+ // console.log(reg.test("ababab"));
|
|
|
+ // console.log(reg.test("abc"));
|
|
|
+ // console.log(reg.test("acbcba"));
|
|
|
+ // console.log(reg.test("acaacac"));
|
|
|
+ // console.log(reg.test("dcdhjhfgjk"));
|
|
|
+
|
|
|
+ // 连字符 -
|
|
|
+ // const reg1 = /[0-9]/
|
|
|
+ // const reg2 = /[a-f]/
|
|
|
+
|
|
|
+ // 取反 ^
|
|
|
+ // const reg3 = /[^a-z]/;
|
|
|
+ // console.log(reg3.test("acaacac"));
|
|
|
+ // console.log(reg3.test("uiuiui"));
|
|
|
+ // console.log(reg3.test("ba8ba"));
|
|
|
+ // console.log(reg3.test("as"));
|
|
|
+
|
|
|
+ // . 除换行以外的任意字符
|
|
|
+ const reg4 = /./;
|
|
|
+ console.log(reg4.test('aaa'))
|
|
|
+ console.log(reg4.test('123456789'))
|
|
|
+ console.log(reg4.test(''));//false
|
|
|
+ console.log(reg4.test('\n'))
|
|
|
+ console.log(reg4.test('\r'))
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|