How to get regex to match multiple script tags?

后端 未结 6 2004
一整个雨季
一整个雨季 2020-12-13 16:01

I\'m trying to return the contents of any tags in a body of text. I\'m currently using the following expression, but it only captures the contents of the first tag and ign

6条回答
  •  温柔的废话
    2020-12-13 16:31

    Don't use regular expressions for parsing HTML. HTML is not a regular language. Use the power of the DOM. This is much easier, because it is the right tool.

    var scripts = document.getElementsByTagName('script');
    

提交回复
热议问题