From: Daniel Carrera Date: 2003-06-11T08:38:55+09:00 Subject: Re: custom capitalization -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Here is a thought: String#capitalize capitalized the first letter. So it doesn't do quite what you want: "john".capitalize #=> "John" "john doe".capitalize #=> "John doe" So I would split, then capitalize, then join: "john doe jr".split.map{|e| e.capitalize}.join(" ") #=> "John Doe Jr" 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-----