Need to find a single <script> condition </script> that contains condition.
The example below contains 4 tags, i need to match the second tag that contains condition and discard the others. Starts with <script>. Before the condition could be space or new line, and than the condition like if (window.location.href == bar) { } and than could be space or new line, and the end </script>.
<script> <!-- discard --->
other stuff
not to be found
</script>
<script> <!-- MATCH --->
if (window.location.href == bar) {
do something
}
</script>
<script> <!-- discard --->
other stuff
not to be found
</script>
<script> <!-- discard --->
other stuff
not to be found
</script>
Thanks in advance