code: def dedent(text):
      
      # Look for the longest leading string of spaces and tabs common to
      # all lines.
      margin = None
      text = _whitespace_only_re.sub('', text)
      indents = _leading_whitespace_re.findall(text)
      for indent in indents:
          if margin is None:
              margin = indent
  
          # Current line more deeply indented than previous winner:
          # no change (previous winner is still on top).
          elif indent.startswith(margin):
              pass
  
          # Current line consistent with and no deeper than previous winner:
          # it's the new winner.
          elif margin.startswith(indent):
              margin = indent
  
          # Find the largest common whitespace between current line and previous
          # winner.
          else:
              for i, (x, y) in enumerate(zip(margin, indent)):
                  if x != y:
                      margin = margin[:i]
                      break
              else:
                  margin = margin[:len(indent)]
  
      # sanity check (testing/debugging only)
      if 0 and margin:
          for line in text.split("\n"):
              assert not line or line.startswith(margin), \
                     "line = %r, margin = %r" % (line, margin)
  
      if margin:
          text = re.sub(r'(?m)^' + margin, '', text)
      return text
docs: Remove any common leading whitespace from every line in `text`.
  
      This can be used to make triple-quoted strings line up with the left
      edge of the display, while still presenting them in the source code
      in indented form.
  
      Note that tabs and spaces are both treated as whitespace, but they
      are not equal: the lines "  hello" and "\\thello" are
      considered to have no common leading whitespace.  (This behaviour is
      new in Python 2.5; older versions of this module incorrectly
      expanded tabs before searching for common leading whitespace.)