import re


def replace(text, bindings):
  """Replace the variables in text with their corresponding bindings.

  Args:
    text: The text to replace has variables in the form $<KEY>
    bindings: A dictionary of binding values keyed by <KEY>.
  """
  regex = re.compile(r'\$(\w+)')
  return regex.sub(lambda match: bindings.get(match.group(1), match.group()),
                   text)