import re


def normalize(text: str) -> str:
    """Remove any non-word characters to make groff output comparable
       across platforms."""
    # Strip the strange escape characters that Groff inserts for TTYs
    text = re.sub(r".\x08", "", text)

    # Strip the header: this varies platform to platform.
    text = text.split("\n", 1)[1]

    # Remove non-word characters
    return re.sub(r"[^\w]+", "", text)