From: Paul Lutus Date: 2006-12-10T17:25:12+09:00 Subject: Re: Capitalization Jason Vogel wrote: > William, > > This is exactly what I'm looking for. I don't understand it, but it's > what I'm looking for. > > Would you mind explaining what your code does? Here is the code the prior poster offered (and please do not top-post -- it makes it hard to reconstruct the thread): puts DATA.read.downcase.split( /([^a-z]+)/ ).map{ |s| specials[s] or s.capitalize }.join Here is the breakdown: DATA.read.downcase Means: "read the data, convert entirely to lowercase" .split( /([^a-z]+)/ ) means: "split the data on non-alphabetic boundaries (which in this case produces an array of entities consisting of words and slashes)" .map{ |s| specials[s] or s.capitalize } Means: "submit each word to a block of code that either succeeds in matching the word with a predefined special set of exceptions or, failing that, capitalizes the word (uppercases the first character)" .join Means: "join the array into one continuous line separated by spaces" Finally, print it all using the very first command on the line -- "puts". -- Paul Lutus http://www.arachnoid.com