golang语言渐入佳境[24]-string-大小写转换类函数

栏目: Go · 发布时间: 7年前

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() {
//
//}

golang语言渐入佳境[24]-string-大小写转换类函数


以上所述就是小编给大家介绍的《golang语言渐入佳境[24]-string-大小写转换类函数》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms Unlocked

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》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具