import re


def _preprocess_flex_link(link):
    """Turn FLEx's cross references into the 'lemma hm' format."""
    m = re.fullmatch(r'(.*?)(\d*)\s*(\d*)', link)
    if not m:
        return link
    lemma, hm, sense_nr = m.groups()
    if hm:
        return '{} {}'.format(lemma, hm)
    return lemma