def before_first_x(text, x):
    """
    before_first_x(str, str) -> str

    >>> before_first_x("enum class Actions", " ")
    'enum'
    >>> before_first_x("enum Actions : byte", " : ")
    'enum Actions'
    >>> before_first_x("enum Actions : ", " : ")
    'enum Actions'
    """
    i = text.find(x)
    if i > -1:
        return text[:i]
    return None