> So I would split, then capitalize, then join: > > "john doe jr".split.map{|e| e.capitalize}.join(" ") #=> "John Doe Jr" > To preserve whitespaces, try: "JOHN doe jr".gsub(/\w+/) { |m| m.capitalize } #=> "John Doe Jr" Gennady. > HTH, > Daniel. > > On Wed, Jun 11, 2003 at 08:34:16AM +0900, Steven Ketcham wrote: > > > > Is there a ruby way to enforce specific capitalization style? > > > > i.e. > > change "JOHN DOE" to "John Doe" > > > > In C++ I search for a space then captalize the next letter and > > capitalize the first letter of the string. > > > > Thanks! > > > > > > - -- > Daniel Carrera | OpenPGP fingerprint: > Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88 > UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.2 (SunOS) > > iD8DBQE+5mwInxE8DWHf+OcRAiFsAKDeqdqV2VyLDmZbRvdxYYfAu/ezFwCeNqNw > 9vmjrNyWW3mcMKGZ7pEo7kY= > =ibnz > -----END PGP SIGNATURE----- > >