On 11/17/06, Peter Schrammel <peter.schrammel / gmx.de> wrote:
> Paul Lutus wrote:
> > Yes, unless he is matching whole words, he is stuck with regexes. There is
> > very likely to be a refactoring for this problem, and it would have to
> > start with a clear statement of the problem to be solved.
> >
> Sorry, my fault.
>
> The problem is to match a whole bunch (>70000) of words (later regexps)
> on a string.
> The actual implementation is to concat the word with | and create a big
> regexp. word1|word2|word3|word4 ...

Is it exact word matching?

if so then you can split the input-string on blankspace,
so you get an array of words. Then you can sort the array of words

irb(main):001:0> a = %w(a b c e f g)
=> ["a", "b", "c", "e", "f", "g"]
irb(main):002:0> b = %w(b d f)
=> ["b", "d", "f"]
irb(main):003:0> a & b
=> ["b", "f"]


--
Simon Strandgaard