[REBOL] Re: Parse versus Regular Expressions
From: g:santilli:tiscalinet:it at: 5-Apr-2003 22:00
Hi Joel,
On Saturday, April 5, 2003, 5:00:08 PM, you wrote:
JN> /(.+)\1+$/
I wonder what is the RE parser doing under the hood. What is the
complexity of such a innocent-looking RE?
JN> I'm really interested in how a PARSE expert would approach the same
JN> task. Any takers?
Well, I wouldn't use PARSE probably. I would do it this way: for
all the divisors of the length of the input string, check to see
if the string is made of a repetition of a substring that has the
length of the divisor. If no solution is found, apply the same
test starting at the next position of the string, recursively.
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r