From: Ross Bamford Date: 2006-11-13T00:40:06+09:00 Subject: Re: regular expression too big On Sun, 12 Nov 2006 15:01:56 -0000, Peter Schrammel wrote: > Why is there a limitation at all? I implemented the same thing in perl > and it no complains ... > Is the regexp engine of perl that much better? > Irrespective of whether regex the best solution for your needs, it seems Oniguruma will improve the situation somewhat with respect to large regular expressions. $ wc -w acd-holmes-return.txt 112110 acd-holmes-return.txt $ cat bigregexp.rb txt = File.read('acd-holmes-return.txt').split(' ') re = /^(#{txt.map { |e| "#{Regexp.escape(e)}" }.join('|')})$/ p re =~ "beautiful" p $& __END__ $ ruby -v bigregexp.rb ruby 1.8.5 (2006-08-25) [i686-linux] bigregexp.rb:2: regular expression too big: /...[snipped].../ (RegexpError) $ ruby9 -v bigregexp.rb ruby 1.9.0 (2006-09-07) [i686-linux] 0 "beautiful" -- Ross Bamford - rosco@roscopeco.remove.co.uk