From: Paul Lutus Date: 2006-12-09T04:40:05+09:00 Subject: Re: Capitalization Jason Vogel wrote: > Disclaimer : Ruby Nuby and I don't know RegEx basically at all. I know > RegEx is the answer, just don't know where to start. > > Current Source: > str.split(' ').each {|w| w.capitalize!}.join(' ') > > Text: > ADDITIONAL SPA (ONLY AVAILABLE W/PURCHASE OF POOL OR SPA) > SELLER HEAT/AC/DUCTWORK > > Result: > Additional Spa (only Available W/purchase Of Pool Or Spa) > Seller Heat/ac/ductwork > > Desired: > Additional Spa (Only Available w/Purchase of Pool or Spa) > Seller Heat/AC/Ductwork > > Isssus: > - Need to capitalize after a "/' > - Need specific word case handling (e.g. "Ac" => "AC","or" => "or", > "w/[a]" => "w/[A]") How many special cases? In the worst case, you would have to use a dictionary to avoid treating acronyms as a word. You already have two rather difficult rules, one having to do with acronyms, another having to do with special treatment of the sequence "w/". What I am saying is this is likely to be more difficult than it seems, especially because we only have one example of what might end up being thousands of examples of free-form text. -- Paul Lutus http://www.arachnoid.com