点击运行
package main import ( "fmt" "strings" ) // Main 函数 func main() { // 初始化字符串 str1 := "Welcome, to the, online portal, of jiyik.com" str2 := "My dog name is Dollar" str3 := "I like to play Ludo" // 显示字符串 fmt.Println("String 1: ", str1) fmt.Println("String 2: ", str2) fmt.Println("String 3: ", str3) // 拆分给定的字符串 // 使用 SplitAfter() 函数 res1 := strings.SplitAfter(str1, ",") res2 := strings.SplitAfter(str2, "") res3 := strings.SplitAfter(str3, "!") res4 := strings.SplitAfter("", "jiyik.com, jiyik") // 显示结果 fmt.Println("\nResult 1: ", res1) fmt.Println("Result 2: ", res2) fmt.Println("Result 3: ", res3) fmt.Println("Result 4: ", res4) }
运行结果 :
正在执行...