From: Hugh Sasse Date: 2006-10-14T02:29:41+09:00 Subject: Re: Regex parsing against filenames On Sat, 14 Oct 2006, Peter Bailey wrote: > Hi, > I need to match incoming filenames in a directory on my server, so that > I can do stuff in a table. In my testing, I've got 9 files: > > pq181b1p.ps pq181b1t.ps pq181b2p.ps pq181b2t.ps pq181b3t.ps > pq192b1p.ps pq192b1t.ps pq192b2t.ps pq192b3p.ps [lines folded] > > Only filenames 1,2,6 and 7 parse against the entry "dbfilename" in my > database. The other 5 don't. The entries, for these files, in the > database are "pq181b" and "pq192b." Shouldn't all 9 of these filenames > parse true against "pq181b" and "pq192b??" > > Here's a snippet of my code, showing where I'm doing the regex. All the > filenames are in the variable $psfile. > > ... > db = KirbyBase.new { |d| d.path = "E:/workflows/graphics/pagecounts" } > pageinfo_tbl = db.get_table(:pageinfo) > > result = pageinfo_tbl.select { |r| $psfile =~ Regexp.new(r.dbfilename) } > ... Without seeing the result of the r.dbfilename call it's hard to tell. result = pageinfo_tbl.select do |r| dbf = r.dbfilename re = Regexp.new(dbf) if re.match($psfile) true else puts "#{r}.dbfilename => #{dbf} => #{re} which failed to match #{$psfile}" false end end might tell you something. > > > Thanks, > Peter > Hugh > -- > Posted via http://www.ruby-forum.com/. > >