G
grrr
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 )
This would mean going through each character in the textblock. I guess one
could conversely go through the replacekey array and match to the
textblock?? Which way to go?
J Von Rubiginner
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 )
This would mean going through each character in the textblock. I guess one
could conversely go through the replacekey array and match to the
textblock?? Which way to go?
J Von Rubiginner