From: MonkeeSage Date: 2007-12-27T11:24:57+09:00 Subject: Re: array.index(obj, start)? On Dec 26, 12:48 pm, Esmail wrote: > Hi > > array.index(obj) will return the index of the item in the array. > > I am unable to find a version of this that allows one to specify > a starting index in place of the default 0 start, is there such a > function? > > Let's say I have a text file that contains multiple records of some sort. > Each record has a unique identifier, but ends with the same character, > say '<'. So, the identifiers are unique, but then end of record markers > are not. > > I read this file into an array of strings and am trying to delete > one or more of these records. The records may not be in order of > deletion. My idea is to set the given range to nil and then use compact! > to delete the lines when I'm done with the "deletions". > > So, one sequence might be like this: > > start=ar.index(starting_name) will give me the starting index > end=ar.index('<', start) would give me the immediate next > end tag (there may be others.) > ar[start...end]=nil > ar.compact! > > Comments/suggestions? I really like Ruby but I am not yet > proficient with it. > > Thanks. s = "stuff "stuff