code: def dropNested(text, openDelim, closeDelim):
      
      openRE = re.compile(openDelim)
      closeRE = re.compile(closeDelim)
      # partition text in separate blocks { } { }
      spans = []                # pairs (s, e) for each partition
      nest = 0                    # nesting level
      start = openRE.search(text, 0)
      if not start:
          return text
      end = closeRE.search(text, start.end())
      next = start
      while end:
          next = openRE.search(text, next.end())
          if not next:            # termination
              while nest:         # close all pending
                  nest -=1
                  end0 = closeRE.search(text, end.end())
                  if end0:
                      end = end0
                  else:
                      break
              spans.append((start.start(), end.end()))
              break
          while end.end() < next.start():
              # { } {
              if nest:
                  nest -= 1
                  # try closing more
                  last = end.end()
                  end = closeRE.search(text, end.end())
                  if not end:     # unbalanced
                      if spans:
                          span = (spans[0][0], last)
                      else:
                          span = (start.start(), last)
                      spans = [span]
                      break
              else:
                  spans.append((start.start(), end.end()))
                  # advance start, find next close
                  start = next
                  end = closeRE.search(text, next.end())
                  break           # { }
          if next != start:
              # { { }
              nest += 1
      # collect text outside partitions
      return dropSpans(spans, text)
docs: A matching function for nested expressions, e.g. namespaces and tables.