[REBOL] Re: Perl is to stupid to understand this 1 liner.
From: carl:cybercraft at: 16-Dec-2001 13:25
On 16-Dec-01, Romano Paolo Tenca wrote:
> Are these correct?
>>> f: "123-123-234-2112-3444" parse/all f [some[a: 1 2[3 c "-"]4 c
> b:(change/part a "####" b) | skip]
> ]print f
> 123-####-3444
No - that's not correct. Joel says phone numbers are of the form
###-#### or ###-###-#### so phoning "123-123-234-2112-3444" would
give you a number-not-found error...
>>> f: "123-234-2112whatisthis?" parse/all f [some[a: 1 2[3 c "-"]4 c
> b:(change/part a "####" b) | s
> kip]]print f
> ####whatisthis?
No, "whatisthis?" is not how you write sentences - words are supposed
to have spaces between them...
> f: "k-123+123-2112*2/4" parse/all f [some[a: 1 2[3 c "-"]4 c
> b:(change/part a "####" b) | skip]]p
> rint f
> k-123+####*2/4
>>> f: "k123123-2112-3444" parse/all f [some[a: 1 2[3 c "-"]4 c
>>> b:(change/part
> a "####" b) | skip]]pri
> nt f
> k123####-3444
Well, 123-4567 could be a phone number or arithmatic too - though to
REBOL's mind it's an invalid date. But the rule is, if in doubt,
blot it out! (:
So, can you write text with phone numbers in of the form ###-#### or
###-###-#### that /won't/ be blotted out by that parsing rule? (Hint:
You can! :)
--
Carl Read