How to get regex to match multiple script tags?

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

    try this

    for each(var x in document.getElementsByTagName('script');
         if (x && x.innerHTML){
              var yourRegex = /http:\/\/\.*\.com/g;
              var matches = yourRegex.exec(x.innerHTML);
                 if (matches){
              your code
     }}
    

提交回复
热议问题