From: Eero Saynatkari Date: 2009-03-19T00:33:52+09:00 Subject: [ruby-core:22928] Re: [Bug #1301] Poor RegExp Matching Performance Excerpts from Marius M��rnes Mathiesen's message of Wed Mar 18 16:53:08 +0200 2009: > Bug #1301: Poor RegExp Matching Performance > http://redmine.ruby-lang.org/issues/show/1301 > > Author: Andreas Grau > Status: Open, Priority: Normal > Category: core > ruby -v: 1.9.0 (2008-06-20 revision 17482) [i486-linux] > > I noticed a very poor performance on matching regular expressions. You mean non-matching? Aside from which, I would be hard-pressed to call the code below a "regular expression." > Running following code using ruby 1.9.0 on a Core2Duo (2x2Ghz) takes more than > 20s to complete. > > regexp = /[b]+.+.+.+.+.+.+.+.+[a]/ > str="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" > regexp.match(str) Are you able to produce a reasonable example of where this is a problem and not just a pathologically horrible regexp? The above, written as: /[b]+.+[a]/ Or: /[b].+.{1,}[a]/ Completes instantly. -- Magic is insufficiently advanced technology.