import re


def swap_sld(fqdn, sld):
  """
  Swap the second-level domain of fqdn with sld. For example, given
  fqdn=jane.domain.org, sld=example.com, return jane.example.com
  """
  r = re.compile(r"(.*\.)?(\w+\.\w+)$")
  m = r.match(fqdn)
  if m is not None and m.group(1) is not None:
    host = m.group(1)
  else:
    host = ''
  return "{}{}".format(host, sld)