From: Peter Bailey Date: 2007-09-20T05:10:06+09:00 Subject: Re: finding string matches, in order, in a file William James wrote: > On Sep 19, 1:06 pm, William James wrote: >> > > been disordered somehow? After your program reads the file >> > the first entry that should be seen is the "Trade" one. >> "Health Issues" appears twice in your output. Returning to my >> original >> hypothesis, are you certain "Trade" doesn't occur twice in the file? >> If it occurs twice, and the reg.ex. fails to match the first instance >> but matches the second, it may appear to you that "Trade" is being >> output out of order, when in fact the first occurrance is simply >> missing. >> If there are more copies of each entry in the file than you suspect, >> a faulty reg.ex. will make it seem that the output is out of order. > > A way to see if the reg.ex. is matching all entries. > grep -c ' If this is more than the 208 lines output by the Ruby program, > then the reg.ex. is probably failing in some cases. Yes, when I grep my original xml file, I see 229 entries. But, with my Ruby script, I only see 208. But, yes, many of these entries do repeat. I'll look more closely at that first entry, the Trade one, to see what might be different about it. Thanks. -- Posted via http://www.ruby-forum.com/.