详细讲解—>https://www.lazycoffee.com/articles/view?id=5d8dbbba94a925069182c5b4

    1. <script>
    2. /*
    3. 给量词的情况下 默认取最大值 默认是贪婪的
    4. */
    5. var str = " a 'witch'nice'broom' and her 'broom' is one";
    6. console.log(str.match(/'.+'/g));//贪婪模式
    7. console.log(str.match(/'.+?'/g));//懒惰模式
    8. </script>
    9. <!-- 过滤标签 -->
    10. <script>
    11. var arr = "<p>dhauwidgwueah</p><p> <div></div><>< ><1>";
    12. /*这里加号是表面[]里面包含多个字符。*/
    13. var reg = /<[^\s]*>/g;
    14. console.log(arr.match(reg));
    15. console.log(arr.match(/<[^\s]*?>/g));
    16. </script>