On 15-Dec-01, Petr Krenzelok wrote:
> Hi,

> Carl used parse without any need to define a rule, e.g. parse
> some-string none will give you a block of strings separated by space

I planned to use a rule at the start, but then noticed that just a
check of length would do the trick.  But then Joel changed the
rules... (;

> But why not to use rule? Because of having everything on one line?
> OK, with rebol - it is pretty legal to have whole script on one line
> (if you don't use comments of course :-), so:

> digits: charset "0123456789" spacer: #"-"
> tel-num: [3 digits spacer some [digits | spacer]] parse/all text
> [some [start: tel-num end: (print copy/part start end) | skip]]
> 555-1212
> 800-555-1111
> 123-4576
> 987-6543
> 111-1111
> == true

> I know that tel-num rule allows for some 999------, but that is
> sufficient for our demo ... Just put on one line, shorten word
> names, and replace rebol code in parens to get your result ...

> If someone finds easier solution (e.g. iteration based) for my
> string replacement, cool then :-)

> hide-it: func [s e][ l: length? copy/part s e remove/part s e
> insert/dup s "#" l)
> parse/all text [some [start: tel-num end: (hide-it) | skip]]

> ; <----- clear and readable, isn't it? :-)

The height of clarity - but it doesn't work. (:  The hide-it func ends
in a ")" not a "]" and where it's used in the parse line the 's and
'e parameters aren't given.  I take it you didn't test it? (:

But never mind.  When fixed it works, unlike what I was doing till I
read your post...

> Well, on the other hand
> not so straightforward as your Perl example ...

Perhaps Joel would now like to write a version in Perl that's designed
to be as clear as possible as apposed to as short as possible?

> Cheers,
> -pekr-

-- 
Carl Read

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to