def insert_mode(page_html, mode):
match_found = False<EOL>matches = re.finditer("<STR_LIT>", page_html)<EOL>match = None<EOL>for match in matches:<EOL><INDENT>match_found = True<EOL><DEDENT>if match_found:<EOL><INDENT>new_html = page_html[: match.end()] + "<STR_LIT>" + mode + page_html[match.end() :]<EOL>return new_html<EOL><DEDENT>else:<EOL><INDENT>raise ExperimentError("<STR_LIT>")<EOL><DEDENT>
Insert mode.