package main
import s "strings"
import "fmt"
var p = fmt.Println
func main() {
? ? p("Contains: ", s.Contains("test", "es")) //是否包含 true
? ? p("Count: ", s.Count("test", "t")) //字符串出現(xiàn)字符的次數(shù) 2
? ? p("HasPrefix: ", s.HasPrefix("test", "te")) //判斷字符串首部 true
? ? p("HasSuffix: ", s.HasSuffix("test", "st")) //判斷字符串結(jié)尾 true
? ? p("Index: ", s.Index("test", "e")) //查詢字符串位置 1
? ? p("Join: ", s.Join([]string{"a", "b"}, "-"))//字符串?dāng)?shù)組 連接 a-b
? ? p("Repeat: ", s.Repeat("a", 5)) //重復(fù)一個(gè)字符串 aaaaa
? ? p("Replace: ", s.Replace("foo", "o", "0", -1)) //字符串替換 指定起始位置為小于0,則全部替換 f00
? ? p("Replace: ", s.Replace("foo", "o", "0", 1)) //字符串替換 指定起始位置1 f0o
? ? p("Split: ", s.Split("a-b-c-d-e", "-")) //字符串切割 [a b c d e]
? ? p("ToLower: ", s.ToLower("TEST")) //字符串 小寫(xiě)轉(zhuǎn)換 test
? ? p("ToUpper: ", s.ToUpper("test")) //字符串 大寫(xiě)轉(zhuǎn)換 TEST
? ? p("Len: ", len("hello")) //字符串長(zhǎng)度
? ? p("Char:", "hello"[1]) //標(biāo)取字符串中的字符,類型為byte
}