使用ruby将句中所有单词首字母大写

2010-05-26  刘俊 

ruby本身的方法里面没有,可以用这个:
str='this is a demo'
puts str.gsub(/\b\w/) { $&.upcase }
858°/8589 人阅读/0 条评论 发表评论

登录 后发表评论