I have an input like the following, where there are two script tags, and the 2nd script tag has src attribute, wherein I need to check if wrapperId={wrapper_id}
is present -
<script type="text/javascript"> var blah; </script><script id="bleh" type="text/javascript" src="//domain/test.js?siteid=270606&testmode=0&banner360=1&banner=0&placementid=0&tp=3&wrapperId={wrapper_id}" > </script>
Following is the regex I have prepared so far -
<script(.*?)(?!<\/script>)(.*?)wrapperId={wrapper_id}(.*?)<\/script>
I am trying to match the script tag which does not contain a closing script tag (</script>
).
However, if I run it at https://regex101.com/r/oZ2jL6/1, I see it matching the 1st script tag.
If I use PHP preg_match(), the result also says that match was found, but I am sure it is matching the 1st script tag, which I don't want.
Already checked related question -
Regular expression to match a line that doesn't contain a word?