code: def expandvars(path):
      
  
      path = path2fsn(path)
  
      def repl_func(match):
          return environ.get(match.group(1), match.group(0))
  
      path = re.compile(r"\$(\w+)", flags=re.UNICODE).sub(repl_func, path)
      if os.name == "nt":
          path = re.sub(r"%([^%]+)%", repl_func, path)
      return re.sub(r"\$\{([^\}]+)\}", repl_func, path)
docs: Args:
          path (pathlike): A path to expand
      Returns:
          `fsnative`
  
      Like :func:`python:os.path.expandvars` but supports unicode under Windows
      + Python 2 and always returns a `fsnative`.