import re


def clean_string(string):
  """Removes ANSI escape sequences and non-alphanumeric chars, and converts to lowercase."""
  string = re.sub(r'\x1B\[[0-?]*[ -/]*[@-~]', "", string)

  ret = []
  for c in string:
    if c.isalnum():
      ret.append(c)

  return "".join(ret).lower()