Bueno tal parece que el tema es que hay dos algoritmos, muy basicamente:

1) Con backtracking
2) Sin bactracing.

Backtracking es cuando usas parte de lo que ya macheaste para machear algo mas, 
por ejemplo "HOLAHOLA".match(/([A-Z]*)\1/) => ['HOLA', 'HOLA'] (\1 significa: 
todo lo que haya macheado adentro de los primeros parentesis que aparezcan).

Tal parece que el hecho de poder usar lo que macheaste dentro de la regex hace 
que algoritmo tome tiempo exponencial, segun me explicaron. Oniguruma no mejora 
esto, no solo tiene backtracking sino tambien lookahead! EL tema es que el 
objetivo no es hacer las regexes super rapidas sino potentes (el clasico 
sacrificio potencia / velocidad, que despues de todo es la razon por la que 
todos nosotros usamos ruby, no? :) )

Saludos!
Emmanuel

<quote>
A backreference like \1 or \2 matches the string matched by  a
previous parenthesized expression, and only that string:  (cat|dog)\1
matches catcat and dogdog but not catdog nor dogcat. As far as  the
theoretical term is concerned, regular expressions with
backreferences  are not regular expressions. The power that
backreferences add comes at great  cost: in the worst case, the best
known implementations require exponential  search algorithms, like
the one Perl uses. Perl (and the other languages)  could not now
remove backreference support, of course, but they could employ  much
faster algorithms when presented with regular expressions that  don't
have backreferences, like the ones considered above.  
</quote>

By Hugh Sasse:

This is not likely to change.  Whether the conditional  cases will be
added is another matter, one might try to persuade someone to  do
this.  But I think many people consider them fast enough, and
another  conditional branch adds that much more testing.  The future
of Ruby's Regexps  lies with Oniguruma, which has lookbehind as well
as Perl5's lookahead, and  other things like named backreferences,
making the code that much more  readable.  Helping the programmer
over helping the computer is pretty much  the philosophy behind
ruby.  To sacrifice this for speed is probably wrong,  think cost of
programmer time vs cost of CPU time.

nelson fernandez <[EMAIL PROTECTED]> escribió: hasta donde leí estaban mirando 
con cariño esta libreria para
reemplazar la actual

http://rubyforge.org/projects/oniguruma


-- 
:: nelson ::
artesano de software
http://netflux.com.ar


On 4/10/07, Emmanuel Oga  wrote:
> Que tal gente estaba leyendo este articulo:
>
> http://swtch.com/~rsc/regexp/regexp1.html
>
> ... y me pregunto si alguno sabe cual es el estado actual (y posible futuro)
> del motor de regexes de ruby con respecto a lo que dice este articulo.
> Saludos y hasta luego,
>
> Emmanuel
> emmanueloga.blogspot.com
>
>
>  ________________________________
>  Preguntá. Respondé. Descubrí.
>  Todo lo que querías saber, y lo que ni imaginabas,
>  está en Yahoo! Respuestas (Beta).
>  Probalo ya!
>
>
> _______________________________________________
> ruby mailing list
> [email protected]
> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>
>
_______________________________________________
ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar


       
---------------------------------
 Preguntá. Respondé. Descubrí.
 Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
 Probalo ya! 
_______________________________________________
ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a