string-大小写转换类函数
package main
import (
"fmt"
"strings"
)
/*
1、func Title(s string) string
将字符串s每个单词首字母大写返回
2、func ToLower(s string) string
将字符串s转换成小写返回
3、func ToLowerSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成小写返回
4、func ToTitle(s string) string
将字符串s转换成大写返回
5、func ToTitleSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成大写返回
6、func ToUpper(s string) string
将字符串s转换成大写返回
7、func ToUpperSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成大写返回
*/
func main() {
TestTitle()
TestToTitle()
TestToLower()
TestToUpper()
}
func TestTitle() {
fmt.Println(strings.Title("her royal highness"))
}
func TestToTitle() {
fmt.Println(strings.ToTitle("louD noises"))
}
//func TestToTitleSpecial() {
//}
func TestToLower() {
fmt.Println(strings.ToLower("Gopher"))
}
//func TestToLowerSpecial() {
//
//}
func TestToUpper() {
fmt.Println(strings.ToUpper("Gopher"))
}
//func TestToUpperSpecial() {
//
//}
-
本文链接: https://dreamerjonson.com/2018/11/30/golang-24-string-package3/
-
版权声明: 本博客所有文章除特别声明外,均采用 CC BY 4.0 CN协议 许可协议。转载请注明出处!
以上所述就是小编给大家介绍的《golang语言渐入佳境[24]-string-大小写转换类函数》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 用 PHP 实现字符串大小写转函数的功能
- ReactNative字体大小不随系统字体大小变化而变化
- JVM 参数最佳实践:元空间的初始大小和最大大小
- 原 荐 java计算对象占用内存大小:lucene专用于计算堆内存占用大小的工具类
- 获取网络图片的大小
- 获取网络图片的大小
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Algorithms Unlocked
Thomas H. Cormen / The MIT Press / 2013-3-1 / USD 25.00
Have you ever wondered how your GPS can find the fastest way to your destination, selecting one route from seemingly countless possibilities in mere seconds? How your credit card account number is pro......一起来看看 《Algorithms Unlocked》 这本书的介绍吧!