# File scripts/ad.rb, line 169
    def split_on_rule(rule, ad)
      # Returns this tp if the rule does not apply 
      return [self] unless @txt =~ rule.match
      
      hash_tp = Hash.new
      res = rule.apply(@txt)
      
      # index of the match.  This also sets $~ to the match object
      match_ind = @txt =~ rule.match
      
      # get tp before match
      tp_b4 = TextPortion.new(@txt.slice(0,match_ind), @pos)
      hash_tp[@pos] = tp_b4
      
      # get tp of the match itself
      ext_atts = Hash.new
      res.each do |n,v|
        # Store the values in the atts hash of hashes
        h = ad.atts[@pos+match_ind]
        h = Hash.new unless h # Initialize h if it was nil
        h[n] = v
        ad.atts[@pos+match_ind] = h
        # Also, we track what fields where extracted for this text section.
        ext_atts[n] = v
      end
      tp_match = TextPortion.new($~[0], @pos+match_ind, true, ext_atts)
      hash_tp[@pos+match_ind] = tp_match
      
      # get tp after match
      end_ind = $~.end(0)
      tp_after = TextPortion.new(@txt.slice(end_ind,@txt.length), @pos+end_ind)
      # if there is another match later in the string, apply this method to the
      # remaining text.
      if tp_after.txt =~ rule.match
        hash2 = tp_after.split_on_rule(rule, ad)
        hash_tp.merge!(hash2) 
      else
        hash_tp[@pos+end_ind] = tp_after
      end
      
      return hash_tp
    end