From: David Alan Black Date: 2001-12-17T00:34:21+09:00 Subject: [ruby-talk:28689] Re: How do you do "character filtering" of a string using each_byte. Hi -- On Mon, 17 Dec 2001, Carlos wrote: > > > 1) all digits are removed. > > > 2) all lowercase are changed to uppercase. > > > 3) multiple spaces are converted to one space > > > 4) tab is converted to one space. > > > > See Jim M.'s answer -- also, here's an example of how to do it by > > chaining some nice String methods: > > > > str = "What\t ever 123 YOU want 2 \t have" > > newstr = str.tr("\t"," ").delete("[0-9]").squeeze.upcase > delete("0-9") > > is better; he doesn't want to remove the brackets. Whoops :-) Force of (bad) habit. Also I realized that, if we go sequentially through the four requirements, the tab conversion should come after the squeezing. I thought of it more as a two-part #3. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav