Hello --

On Sun, 16 Dec 2001, Thaddeus L. Olczyk wrote:

> I'm trying to do several things where I produce new strings from old
> strings by manipulating characters, and am stuck.
> As an example (please keep in mind this is an example and I am
> interested in the general technique ), consider a method which takes
> a string and produces a new string such that:
> 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
  p newstr # => "WHATEVER YOU WANT HAVE"


I know you want to do more than just this one case, but this might
point you toward some ideas that you use more generally.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav