Bug #1197: regular expression never finishes
http://redmine.ruby-lang.org/issues/show/1197

Author: Péter Szabó
Status: Open, Priority: Normal
ruby -v: ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux]

'a foobarfoobar foobarfoobar"'.scan(/^(([^"\n]*|"([^"]|"")+")+)($)/m)

I tried with Debian-testing, Gentoo-stable Ruby1.8 and Debian-testing Ruby1.9, the results are same: the command never finishes, CPU usage 100%.

Is this a bad regular expression? If it is, how can I know? 

I am neither a master nor a fan of PHP, I just tried it before filing a bug because of curiosity:

<?php

$a = preg_split('/^(([^"\n]*|"([^"]|"")+")+)($)/','a foobarfoobar foobarfoobar"');
echo $a[0];

?>

which exits normally. Not in Ruby, with or without the multiline.


----------------------------------------
http://redmine.ruby-lang.org