def clear_username(string):
    """ because mongo usernames have special requirements """
    string = string.strip()
    if string.startswith('$'):
        string = string[1:]
    try:
        string = string[:string.index('@')]
    except ValueError:
        pass
    return string.replace('.', '')
