From: "rpardee@..." Date: 2005-10-08T07:46:50+09:00 Subject: Re: Code for title-casing (US) snail addresses? And thanks again! If I can beg your indulgence a bit further... I'm having trouble elaborating this so it does the right thing for street names like 'McGrath'. The simpler version is: def prettify(address) abbreviations = %w(PO NE NW SE SW) prefixes2 = %w(Mc O' D') prefixes3 = %w(Mac) address.gsub!(/(\d)([A-Z]+)/) { $1 + $2.downcase } address.gsub(/[A-Z]+/) do |w| # abbreviations.include?(w) ? w : w.capitalize if abbreviations.include?(w) then w else w.capitalize end end end Which works admirably, except it gives back "Mcgrath", rather than "McGrath". I *thought* I'd be able to tack a second Array.include? on there, like so: def prettify(address) abbreviations = %w(PO NE NW SE SW) prefixes2 = %w(Mc O' D') prefixes3 = %w(Mac) address.gsub!(/(\d)([A-Z]+)/) { $1 + $2.downcase } address.gsub(/[A-Z]+/) do |w| # abbreviations.include?(w) ? w : w.capitalize if abbreviations.include?(w) then w else w.capitalize end if prefixes2.include?(w[0..1]) then w[2..2] = w[2..2].upcase end end end But when I do that, calls like prettify("20 E MCGRAW ST") just return "20" I've read over the gsub docs, but don't see why the above does not work as expected. Anybody got a clue for me? Thanks! -Roy