| 12345678910111213141516171819202122232425262728 |
- <!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>
- // \b单词边界
- // const reg = /\baa\b/gi;
- // const str1 = 'aa';
- // console.log(str1.match(reg));
- // // ^匹配字母首行
- // const reg1 = /^ab/;
- // console.log(reg1.test("abyudsyuayuasab"));
- // // $匹配字母尾行
- // const reg2 = /ab$/;
- // console.log(reg2.test("abyudsyuayuasabaaa"));
- const reg3 =/^a$/;
- console.log(reg3.test("aaa"));
- console.log(reg3.test("a"));
- console.log(reg3.test(" "));
- </script>
- </body>
- </html>
|