字符串 – 大写Scala中每个单词的第一个字母
发布时间:2020-12-16 09:40:29 所属栏目:安全 来源:网络整理
导读:我知道这样 val str=org.apache.commons.lang.WordUtils.capitalizeFully("is There any other WAY")) 想知道有没有其他办法做同样的事情。 在Scala风格的东西 解决方法 大写字符串的第一个字母: "is There any other WAY".capitalizeres8: String = Is The
我知道这样
val str=org.apache.commons.lang.WordUtils.capitalizeFully("is There any other WAY")) 想知道有没有其他办法做同样的事情。 在Scala风格的东西 解决方法
大写字符串的第一个字母:
"is There any other WAY".capitalize res8: String = Is There any other WAY 大写字母中每个单词的第一个字母: "is There any other WAY".split(' ').map(_.capitalize).mkString(" ") res9: String = Is There Any Other WAY 将字符串的第一个字母大写,同时将其他所有内容全部缩小: "is There any other WAY".toLowerCase.capitalize res7: String = Is there any other way 将每个单词的第一个字母大写为一个字符串,同时将其他所有内容全部缩小: "is There any other WAY".toLowerCase.split(' ').map(_.capitalize).mkString(" ") res6: String = Is There Any Other Way (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |