[REBOL] Re: Parse versus Regular Expressions
From: lmecir:mbox:vol:cz at: 6-Apr-2003 0:08
> I've just tripped over a tidy example of a task that's trivial to
> solve if backtracking is available.
> Find a repeated group of characters at the end of a string (one or more
> characters, repeated two or more times consecutively). For example,
> "my doggyoggy"
> "has as as as as "
> Note that some cases can be solved in multiple ways:
> in which case any solution is OK.
> The Perl/Python/etc-style regular expression which tests for this
> situation and provides the first occurrence of the repeated group
> of characters is
> which, for those not familar with RE "line noise" ;-) can be read
> (.+) a group (the parens) of one or more (the plus)
> arbitrary characters (the dot)
> \1 ... followed by the same group previously matched
> + ... one or more times
> $ ... at the end of the string
> I'm really interested in how a PARSE expert would approach the same
> task. Any takers?
x1: [end: (x2: copy/part start end) x2]
x3: to-rule x1
x4: [start: skip x3 to end]
parse head reverse "my doggyoggy" x4