12345678910111213141516171819 |
- <!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>
- // 修饰符
- // i 不区分大小写
- // g 全局匹配
- const reg = /hi/gi;
- console.log(reg.test("hello,haha,iloHi"))
- const str = 'hI, an Orange, HI, an Apple';
- console.log(str.match(reg));
- </script>
- </body>
- </html>
|