[REBOL] Re: Perl is to stupid to understand this 1 liner.
From: carl:cybercraft at: 14-Dec-2001 20:49
On 14-Dec-01, Joel Neely wrote:
> That said, I can play parlor games too! (To avoid appearing to
> contradict myself, let me point out that I don't take this exercise
> at all seriously...)
> SUPPOSE that I have a memo containing phone numbers. I need to give
> someone a copy of the memo, but need to blot out the phone numbers,
> in the best CIA tradition. ;-) Here's the memo:
> 8<----------
> Ms. Antoinette,
> I spoke with George Washington at 555-1212 about our pending
> contract. He referred me to Ben Franklin (800-555-1111) of
> their technical support department. Ben said that they were
> testing their latest release on WhizBangOS version 17.3 as
> we had requested, and that he would have our answer tomorrow.
> Ben also said that their lead developer, Betsy Ross, would
> like to talk to you about the use of complex numbers in the
> SystemSleepFor function. You may call her office at
> 123-4576, her cell phone at 987-6543, or page her at 111-1111.
> She is very eager to describe this new feature.
> Sincerely,
> Thomas Paine
> 8<----------
> I can protect everybody's phone numbers from lurking telemarketers
> with the following one-liner in Perl:
> 8<----------
> # perl -p -e 's/\b(\d{3}-)?\d{3}-\d{4}/####/g' memo.txt
> Ms. Antoinette,
> I spoke with George Washington at #### about our pending
> contract. He referred me to Ben Franklin (####) of
> their technical support department. Ben said that they were
> testing their latest release on WhizBangOS version 17.3 as
> we had requested, and that he would have our answer tomorrow.
> Ben also said that their lead developer, Betsy Ross, would
> like to talk to you about the use of complex numbers in the
> SystemSleepFor function. You may call her office at
> ####, her cell phone at ####, or page her at ####.
> She is very eager to describe this new feature.
> Sincerely,
> Thomas Paine
> 8<----------
> Anyone is welcome to propose a minimalist solution in REBOL!
A two-liner is the best I can do Joel...
rebol[]foreach n parse/all f: read %memo.txt " ^/(),."[if 1 < length?
parse/all n "-"[change/part find f n "####" length? n]]print f
It could've been a bit shorter by making duplicate 1-character words
for 'parse and 'length but we want to keep it "readable", right? (:
--
Carl Read