```
>>> html = """<body>Toto</body></html>"""
>>> import re
>>> INSERT_BEFORE = "</body>"
>>> pattern = re.escape(INSERT_BEFORE)
>>> bits = re.split(pattern, html, flags=re.IGNORECASE)
>>> bits
['<body>Toto', '</html>']
>>> bits[-2] = '<script></script>'
>>> bits
['<script></script>', '</html>']
>>> INSERT_BEFORE.join(bits)
'<script></script></body></html>'
```