golang語言漸入佳境[24]-string-大小寫轉換類函式
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() { // //}
-
本文連結: ofollow,noindex">https://dreamerjonson.com/2018/11/30/golang-24-string-package3/
-
版權宣告: 本部落格所有文章除特別宣告外,均採用 CC BY 4.0 CN協議 許可協議。轉載請註明出處!