Issue #1301 has been updated by Andreas Grau.


> Theory about regular expressions (formal language theory)
> says there shouldn't be any difference, but Ruby regular
> expressions (same for Perl, Python, and so on) are not
> really regular expressions in the formal sense anymore,
> because they allow capturing and many more neat practical
> things. So the implementation uses backtracking, and
> your regexp above creates a lot of backtracking.

I agree that python is also ineffizient, however, it is in
my tests 10 times faster when testing this regexp.

What I'm not sure if regexp parsing really requires backtracking.
The Unix command sed for matching and group capturing requires
below 10ms. (ruby ~10s, python ~1s).

regexp=/(\d*) +(\d*) +(\d*) +(\d*) +(\d*) +(\d*) +(\d*) +(\d*) +(\d+)$/
str="                              #"

BTW, a trivial optimization would be to test matching of the regexp using
fast DFA/NFA automat and in case of a matching, use backtracking...


----------------------------------------
http://redmine.ruby-lang.org/issues/show/1301

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