From: Eric Hodel Date: 2006-02-15T08:53:51+09:00 Subject: Re: simple programming q On Feb 14, 2006, at 3:33 PM, grrr wrote: > I am a ruby newbie. I want to make a simple script that replaces > certain > characters in a block of text with specific other characters. > > I am wondering what kind of loop or algo is thought to be most > effective > for this kind of work.. > Maybe go through the block of text with a hashing table and replace > each 'hit'? Would this be reasonable approach? > > #example pseudocode idea > blokoftxt = 'Theres some text in block.' > replacekey = { 'T' = 'W', 'a' = 'o', 'o' = 'a' } > > blokoftxt.each ( if equal to a replacekey, replace with key value ) blokoftxt.tr 'Tao', 'Woa' -- Eric Hodel - drbrain@segment7.net - http://segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com