From: Kirk Haines Date: 2004-08-13T01:11:59+09:00 Subject: Implementation ideas? Flexible string matching Here is the puzzle. You have a string. You have a list of strings and/or regular expressions. You want to find the match, if any, between your string and an element in the list. If the list is also just strings, you can create a hash with the strings as keys then do a hash lookup to do the match. That's fast, even if the list is very long. However, what is most of the list is string literals, but you want to be able to use regexps or some sort of wildcard matching for some of the matches, too. Does anyone have any bright ideas about how to do this as quickly as possible? 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? Thanks, Kirk Haines