From: James Gray Date: 2011-07-17T22:23:04+09:00 Subject: [ruby-core:38138] [Ruby 1.9 - Bug #5038] Ruby 1.9.2 stops on some Regular Expressions Issue #5038 has been updated by James Gray. Your regular expression is exponential, with a repeater (+) inside a repeater (*). It requires the regex engine to do a ton of backtracking, creating the seemingly endless loop. A lot of languages would choke on an expression like that. ---------------------------------------- Bug #5038: Ruby 1.9.2 stops on some Regular Expressions http://redmine.ruby-lang.org/issues/5038 Author: Bob Ambartsumov Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] # Code to reproduce: n = 50 st = "Phone" + " "*n + "Fax" st.match(/(.+\s)*email/i) nil is expected The execution stops on match, or enters some endless loop. CPU load is high. Works as expected when not using /i (case-insensitive) Works as expected on smaller n (<20) Takes about 5 seconds to execute on n=30 -- http://redmine.ruby-lang.org