On Tue, Sep 23, 2003 at 06:29:58PM +0200, Yvon Thoraval wrote:
> Recently, i get a vintage list (more than 500 items) with poor typo, for
> example, i've :
> 
> Ce de beaune-villages
> 
> instead of :
> 
> Ce de Beaune-Villages
> 
> Crant d'alsace
> 
> instead of :
> 
> Crant d'Alsace
> 
> i wonder of the way to change lower to upper case and also of
> 
> a regex able to do the trick.
> 
> something like :
> 
> every letter following a " ", "-" or "'" should be upper if not
> belonging to a black list of words :
> 
> black_list = %w{d de du la le sec sur entre etc...}

string.gsub!(/\b[a-z]+/) { |w| black_list.include?(w) ? w : w.capitalize  }

-Mark