package main
import (
"fmt"
"strings"
)
func main() {
//判斷父字符串是否包含子字符串,包含為真,否則為假
fmt.Println("-------------------------------")
fmt.Println("contains Function:", strings.Contains("Austrilia", "lia"))
fmt.Println("contains Function:", strings.Contains("Austrilia", "mia"))
//子字符串在父字符串中出現(xiàn)的次數(shù)
fmt.Println("-------------------------------")
fmt.Println("Count Function: ",strings.Count("Australia", "lia"))
fmt.Println("Count Function: ",strings.Count("Australia", "A"))
fmt.Println("Count Function: ",strings.Count("Australia", "Bu"))
//判斷子字符串是否為父字符串的前綴
fmt.Println("-------------------------------")
fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Bu"))
fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Aus"))
////判斷子字符串是否為父字符串的后綴
fmt.Println("-------------------------------")
fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "lia"))
fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "tia"))
//子字符串首次出現(xiàn)在父子符串的索引下標
fmt.Println("-------------------------------")
fmt.Println("Index Function:",strings.Index("Australia", "lia"))
fmt.Println("Index Function: ",strings.Index("Australia", "a"))
fmt.Println("Index Function: ",strings.Index("Australia", "A"))
//連接函數(shù),指定分隔符將字符串連接起來
fmt.Println("-------------------------------")
fmt.Println("Join Functions:",strings.Join([]string{"Austrilia", "Japen", "Germany"}, "-"))
fmt.Println("Join Function: ",strings.Join([]string{"Australia","Japan","Germany"}," "))
//重復(fù)函數(shù),指定字符串重復(fù)出現(xiàn)的次數(shù)
fmt.Println("-------------------------------")
fmt.Println("Repeat Function:", strings.Repeat("Australia",3))
//替換字符串函數(shù),
fmt.Println("-------------------------------")
fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",1))
fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",2))
fmt.Println("Replace Function: ",strings.Replace("Aaustralia ","a","b",3))
fmt.Println("Replace Function: ",strings.Replace("Australia ","A","B",1))
fmt.Println("Replace Function: ",strings.Replace("Australia ","lia","pia",1))
//分割函數(shù),指定分隔符分隔字符串
fmt.Println("-------------------------------")
fmt.Println("Split Function:", strings.Split("Australia-Japan-Germany","-"))
//把字符轉(zhuǎn)小寫
fmt.Println("-------------------------------")
fmt.Println("ToLower Function: ",strings.ToLower("Australia"))
//把字符串轉(zhuǎn)大寫
fmt.Println("-------------------------------")
fmt.Println("ToUpper Function: ",strings.ToUpper("Australia"))
}
創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國云服務(wù)器,動態(tài)BGP最優(yōu)骨干路由自動選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機房獨有T級流量清洗系統(tǒng)配攻擊溯源,準確進行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動現(xiàn)已開啟,新人活動云服務(wù)器買多久送多久。
10多年的鄠邑網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整鄠邑建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)公司從事“鄠邑網(wǎng)站設(shè)計”,“鄠邑網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
網(wǎng)站標題:字符串函數(shù)在golang中的使用-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://jinyejixie.com/article46/dsihhg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、網(wǎng)站維護、動態(tài)網(wǎng)站、網(wǎng)站設(shè)計公司、服務(wù)器托管、標簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容