import re


def standardize_annotator(annotation, annotator="annotator"):
    """Substitute coder name in annotation for annotator."""
    # Anvil line for coder: <info key="coder" type="String">TMW</info>
    # regex matches line prior to the coder name in group 1, coder name
    # in group 2, and remainder in group 3, so return string with group
    # 2 substituted as 'annotator'
    return re.sub(
        r"(<.+key=\"coder\".+>)(.+)(</info>)", r"\1" + annotator + r"\3", annotation
    )