import re


def alphanum_split(key):
    """Split the key into a list of [text, int, text, int, ..., text].

    Args:
      key (str): String to split.
    Returns:
      list: List of tokens
    Examples:
      ::

        >>> alphanum_split("hello1world27")
        ['hello', 1, 'world', 27, '']
        >>> alphanum_split("1istheloneliestnumber")
        ['', 1, 'istheloneliestnumber']
    """
    def text_to_int(text):
        """Convert number strings to ints, leave other strings as text.

        Args:
          text (object): Input to convert (str or int)
        Returns:
          object: Converted value (str or int)
        """
        return int(text) if text.isdigit() else text

    return [text_to_int(c) for c in re.split('([0-9]+)', key)]