From: Roman Hausner Date: 2006-07-28T07:14:12+09:00 Subject: Re: Slow regular expressions :( Caleb Clausen wrote: > If you take out the first \s* (or move it outside the parens), the > slowness goes away. That first \s* isn't needed. Another trick that > may help here is changing the *'s to +'s. > > This is a case of pathological backtracking. Usually, these things are > solved by carefully tuning the Regexp, rather than expecting the > Regexp engine to fix it... > No. I am not looking for help on regular expressions here and I know that this particular expression could be optimized. I also know that some regular expressions with backtracking can get exponentially slow. However, regular expression can get generated automatically or there could be other reasons why an optimization a la perl is helpful. The example simply points out that ruby uses a strategy that does not do the optimization that is present in perl. My question was, whether Ruby is going to fix this. If you can answer that question, I would apreciate it. If not, maybe somebody else can. -- Posted via http://www.ruby-forum.com/.