From: "duerst (Martin Dürst)" Date: 2012-03-25T16:09:23+09:00 Subject: [ruby-core:43631] [ruby-trunk - Feature #4822][Rejected] String#capitalize improvements Issue #4822 has been updated by duerst (Martin D��rst). Status changed from Open to Rejected yeban (Anurag Priyam) wrote: > > Hmm, how about this? > > str.gsub(/\w.*?[.!?](?:\s+|\z)/){|c|c.capitalize} > > This solves my problem better than what I was doing. Thanks. Do you > think that other's could also benefit from such an extension to > `capitalize`, or is it better done problem specific? We have discussed this issue at today's developers' meeting in Akihabara. This kind of processing is not only dependent on language, but even for a specific language needs a lot of information to do a reasonable job. To do it perfectly seems to require human intervention. Therefore, we think it is better if requirements like this are addressed with problem-specific solutions. We are therefore rejecting this issue. ---------------------------------------- Feature #4822: String#capitalize improvements https://bugs.ruby-lang.org/issues/4822#change-25131 Author: yeban (Anurag Priyam) Status: Rejected Priority: Normal Assignee: Category: Target version: I think it would be helpful if `String#capitalize` could capitalize _sentences_, and not just the first letter of a string. We could optionally pass a regexp to identify sentence boundaries. If we don't pass this parameter `capitalize` behaves as before. s = "hey all! wassup? i am good." # current capitalize s.capitalize #=> "Hey all! wassup? i am good." # new capitalize s.capitalize #=> "Hey all! wassup? i am good." s.capitalize(/[?!.] /) #=> "Hey all! Wassup? I am good." I am not sure what would it take to implement this. -- http://bugs.ruby-lang.org/