# File lib/Dnsruby/resource/resource.rb, line 369
    def RR.new_from_string(rrstring)
      # strip out comments
      # Test for non escaped ";" by means of the look-behind assertion
      # (the backslash is escaped)
      rrstring.gsub!(/(\?<!\\);.*/o, "");
      
      if ((rrstring =~/#{@@RR_REGEX}/xo) == nil)
        raise Exception, "#{rrstring} did not match RR pat.\nPlease report this to the author!\n"
      end
      
      name    = $1;
      ttl     = $2.to_i || 0;
      rrclass = $3 || '';
      
      
      rrtype  = $4 || '';
      rdata   = $5 || '';
      
      if rdata
        rdata.gsub!(/\s+$/o, "")
      end
      
      # RFC3597 tweaks
      # This converts to known class and type if specified as TYPE###
      if rrtype  =~/^TYPE\d+/o
        rrtype  = Dnsruby::Types.typesbyval(Dnsruby::Types::typesbyname(rrtype))
      end
      if rrclass =~/^CLASS\d+/o
        rrclass = Dnsruby::Classes.classesbyval(Dnsruby::Classes::classesbyname(rrclass))
      end
      
      
      if (rrtype=='' && rrclass && rrclass == 'ANY')
        rrtype  = 'ANY';
        rrclass = 'IN';
      elsif (rrclass=='')
        rrclass = 'IN';
      end
      
      if (rrtype == '')
        rrtype = 'ANY';
      end
      
      if (implemented_rrs.include?(rrtype) && rdata !~/^\s*\\#/o )
        subclass = _get_subclass(name, rrtype, rrclass, ttl, rdata)
        return subclass
      elsif (implemented_rrs.include?(rrtype))   # A known RR type starting with \#
        rdata =~ /\\\#\s+(\d+)\s+(.*)$/o;
        
        rdlength = $1.to_i;
        hexdump  = $2;
        hexdump.gsub!(/\s*/, "");
        
        if hexdump.length() != rdlength*2
          raise Exception, "#{rdata} is inconsistent; length does not match content"
        end
        
        rdata = [hexdump].pack('H*');
        
        return new_from_data(name, rrtype, rrclass, ttl, rdlength, rdata, 0) # rdata.length() - rdlength);
      elsif (rdata=~/\s*\\\#\s+\d+\s+/o)
        #We are now dealing with the truly unknown.
        raise Exception, 'Expected RFC3597 representation of RDATA' unless rdata =~/\\\#\s+(\d+)\s+(.*)$/o;
        
        rdlength = $1.to_i;
        hexdump  = $2;
        hexdump.gsub!(/\s*/o, "");
        
        if hexdump.length() != rdlength*2
          raise Exception, "#{rdata} is inconsistent; length does not match content" ;
        end
        
        rdata = [hexdump].pack('H*');
        
        return new_from_data(name,rrtype,rrclass,ttl,rdlength,rdata,0) # rdata.length() - rdlength);
      else
        #God knows how to handle these...
        subclass = _get_subclass(name, rrtype, rrclass, ttl, "")
        return subclass
      end
    end