How does a regular match a complete script tag

html is as follows:

<body>
    <temlate></template>
    <script>
        var str = `<script>var html="abc";</script>
                    <style></style>
                `;
    </script>
    <style></style>
</body>

how to match:

<script>
    var str = `<script>var html="abc";</script>
                <style></style>
            `;
</script>

if you step on the problem, would you please tell me where the problem needs to be improved? Just step on it?

Mar.05,2021

View matching results


html.match(/<script[^>]*>(?:.*?)<\/script>/)[0]
Menu