Ruby capitalize every word first letter

前端 未结 8 814
名媛妹妹
名媛妹妹 2020-12-12 10:47

I need to make the first character of every word uppercase, and make the rest lowercase...

manufacturer.MFA_BRAND.first.upcase

is only sett

8条回答
  •  清歌不尽
    2020-12-12 11:30

    Another option is to use a regex and gsub, which takes a block:

    'one TWO three foUR'.gsub(/\w+/, &:capitalize)
    

提交回复
热议问题