Use a regex as shown below:
<script>([\s\S]*?)</script>
In javascript we can not do . dotall, so we use the character class [\ s \ S], which matches any space or space character, including a new line. ? for non-greedy matching, so you don't embed script tags.
source share