[REBOL] Re: Parse versus Regular Expressions
From: rotenca:telvia:it at: 6-Apr-2003 3:06
Hi Joel,
> The Perl/Python/etc-style regular expression which tests for this
> situation and provides the first occurrence of the repeated group
> of characters is
>
> /(.+)\1+$/
This is a solution with an error! jump out parse statement, can be done also
with another stop rule, it it seems too much tricky (BTW, reversing the string
before parsing it, leads to a more direct solution):
stop-true: [end skip]
if error? set/any 'res try [
parse/all "my doggyoggy" [
some [
s: (len: (length? s) / 2 n: 0 stop: none)
some [
(if len < n: n + 1 [stop: stop-true])
stop
:s opt [copy x n skip some x end (make error! s)]
]
skip
]
]
][
res: disarm res print res/arg1
]
---
Ciao
Romano