From: 7stud -- Date: 2009-09-03T05:16:03+09:00 Subject: Re: confusing string parsing problem Matt Brooks wrote: > Last 2 byte field: 0 > > > And At this point I need the sub_elements string to not contain any of > the above parameters printed out, ie. whatever I display is done with > and needs to be deleted out of the front of the string. > You could do that simply like this: chop_size = 2 + 2 + 1 + results[3].length + 1 + results[4].length + 1 + 1 puts chop_size --output:-- 16 For example: data = "" data << 0.chr << 3.chr data << 0.chr << 0.chr data << 1.chr data << "BFO" << 0.chr data << "-8000" << "\000" data << 0.chr << 0.chr data << "the rest" results = data.unpack("n2CZ*Z*n") chop_size = 2 + 2 + 1 + results[3].length + 1 + results[4].length + 1 + 1 puts chop_size --output:-- 16 puts "-->#{data[chop_size..-1]}<---" --output:-- -->the rest<--- -- Posted via http://www.ruby-forum.com/.