import re
with open('app/modules/sag/templates/detail.html', 'r', encoding='utf-8') as f:
    text = f.read()

m = re.search(r'function renderTimeV1Timeline\(entries\)\s*{.*?timeline\.innerHTML = Object\.entries\(grouped\).*?\}', text, re.DOTALL)
if m:
    with open('old_js.txt', 'w') as out:
        out.write(m.group(0))
        print("Wrote js")
