[REBOL] Re: Parse versus Regular Expressions
From: lmecir:mbox:vol:cz at: 5-Apr-2003 8:59
Hi,
> in Perl would be something like
>
> $somestring =~ /^(a*)(b*)$/ and length ($1) == length ($2)
, which is Perl, not RE...
> While the content identification and the length equality take two
> different sub-expressions, I'm wondering what happens if we make the
> problem just a little larger, and try to match any of
>
> ""
> "abc"
> "aabbcc"
> "aaabbbccc"
>
> and so on. Using an RE to get content, and then checking lengths,
> is easy to write and understand (and the pattern scales up to more
> than two pieces of content), as follows:
>
> $somestring =~ /^(a*)(b*)(c*)$/ and
> length ($1) == length ($2) and
> length ($2) == length ($3)
>
> and so on for four or more "pieces".
Again, Perl, not RE. Parse dialect:
x: [start: any #"a" end: (n: offset? start end) n #"b" n #"c"]
Regards
-Ladislav