From: Robert Klemme Date: 2004-08-13T04:41:10+09:00 Subject: Re: Implementation ideas? Flexible string matching "Kirk Haines" schrieb im Newsbeitrag news:20040812173551.M70191@enigo.com... > On Fri, 13 Aug 2004 01:41:10 +0900, Martin DeMello wrote > > Kirk Haines wrote: > > > > > The only idea that I have come up with is to put the literal matches in > a > > > hash, and then have the regular expressions in an array. If there isn't > a > > > literal match, then one has to accept the time consuming process of > > > iterating through each regexp and checking it. Can anyone think of any > > > other approaches that might be faster? > > > > If you only need to know that there is a match, rather than what > > matched, how about combining all the regexps into one big regexp using > > ((re1)|(re2)|...)? > > Hmmm. Interesting idea. I'll have to give it a try and see if there is a > performance difference when doing that. I was going to suggest the same: hash and a combined regexp. You could even create a single regexp that coevers all - if that doesn't blow up the regexp engine. I once made a script that takes a list of strings and creates a single regexp from them that is supposedly matched fast (i.e. doesn't need backtracking). If you're interested I can check at work tomorrow - I'm quite sure I still have it somewhere (please email as reminder). Kind regards robert