|
|
@@ -0,0 +1,35 @@
|
|
|
+<!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("ababba"));
|
|
|
+ // console.log(reg.test("abc"));
|
|
|
+ // console.log(reg.test("acbab"));
|
|
|
+ // console.log(reg.test("acacaca"));
|
|
|
+ // console.log(reg.test("ddfffdf"));
|
|
|
+
|
|
|
+ // 连字符 -
|
|
|
+ // const reg1 = /0-9/;
|
|
|
+ // console.log(reg1.test('121s'));
|
|
|
+
|
|
|
+ // // 取反 ^
|
|
|
+ // const reg2 = /[^a-z]/;
|
|
|
+ // console.log(reg2.test('32'));
|
|
|
+
|
|
|
+ // . 匹配换行外的任意字符
|
|
|
+ const reg3 = /./;
|
|
|
+ console.log(reg3.test("Aaaa"));
|
|
|
+ console.log(reg3.test("1234578765432"));
|
|
|
+ console.log(reg3.test("")); // false
|
|
|
+ console.log(reg3.test("\n"));
|
|
|
+ console.log(reg3.test("\r"));
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|