How to get regex to match multiple script tags?

后端 未结 6 2002
一整个雨季
一整个雨季 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:40

    Try using the global flag:

    document.body.innerHTML.match(/([\s\S]*?)<\/script>/gmi)
    

    Edit: added multiple line and case insensitive flags (for obvious reasons).

提交回复
热议问题