From: Eric Hodel Date: 2006-09-05T08:15:38+09:00 Subject: Re: Compiling Regexp only once On Sep 4, 2006, at 5:15 AM, singsang wrote: > Writing some httpd logfile pre-processing (splitting it up, getting > already some basic numbers), I think that I should compile the Regexp > for the logfile entry only once. You should benchmark, I expect you will find you made matching slower. > So my guess is that I should have perhaps a class LogFormat that holds > this as a class variable or a class constant. Below I use a non-tested > regular expression that is not complete yet. > > class LogLine > # ... > ip, rfc931, user, day, month, year, offset = > line.match(LogFormat.regex) > # ... > end #match is the slowest way to use regular expressions. [ruby-talk:204747] -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com