def string_contains_environment_var(string):
    """Determines whether or not there is a valid environment variable in the string"""
    parts = string.split('$')
    if len(parts) == 1:
        return False
    for index, part in enumerate(parts):
        if len(part) == 0:
            continue
        if not part[0].isalpha():
            continue
        if index > 0:
            prev_part = parts[index - 1]
            if prev_part.endswith('\\'):
                continue
            else:
                return True
        elif not part.endswith('\\') and index + 1 != len(parts):
            return True
    return False
