Peter Schrammel wrote:

> Hi,
> 
> got  problem with big regexes:
> I have a regex of about 70000+ words concated with '|' that I'd like to
> match as a regex. /bla|blub|foo|bar|.....(70000)/

It appears you are trying to match a word against a list of words. Yes? From
an efficiency standpoint, if the expression is really as shown (no real
regex syntax), why not create a hash out of the data and see if the desired
word is present that way? That would likely be much faster than running the
(non-regex) regex against each word in the input data.

When you post an question like this, it is always a good idea to reveal the
purpose as well as the method.

------------------------------------------

#!/usr/bin/ruby -w

data = File.read("/usr/share/dict/words")

words = data.split(%r{\s+}m)

hash = {}

words.each do |word|
   hash[word] = true
end

while true
   print "Enter a word:"
   word = STDIN.readline.chomp
   if hash[word]
      puts "Valid word."
   else
      puts "Not present."
   end
end

------------------------------------------

Now you have a hash that can be used for testing a list of words.

-- 
Paul Lutus
http://www.arachnoid.com