From: William James Date: 2007-09-18T22:15:08+09:00 Subject: Re: finding string matches, in order, in a file Peter Bailey wrote: > Hi, > I've got files I want to parse. I'm using a string scan routine that > populates an array. I need to pull the entries of that array out, in > order, eventually. I'm getting an array all right, but, I don't > understand its order. The first instance in the string, meaning the > whole file, is way down the list in the array. The first entry in the > array is an entry that's 300 lines deep into the file. Why isn't the > first instance in the string, the file, the first entry in the array? The file may have multiple copies of some entries, and your regexp may be botched. > > xmlfile.scan(/\n(.*)<\/issue>\n?/) I don't like the looks of that regular expression. Try this one. /\n(.*?)<\/issue>\n?/m