import re


def normalize_hostname_to_rfc(mystr):
    """
    Given a hostname, normalize to Nextdoor hostname standard

    Args:
      mystr (str): hostname to normalize

    Returns:
      normalized hostname

    Details:
      * lower everthing
      * delete anything which is not alphanumeric
      * compress multiple '.' or '-'
      * strip leading '-'s
    """
    return re.sub('^[-]+', '', re.sub('[.]{2,}', '.', re.sub('[-]{2,}', '-', re.sub('[^a-z0-9-._]', '', mystr.lower()))))