This is a creation in Article, where the information may have evolved or changed.
package main import s "Strings" import "fmt" var p = fmt. Println func main () { p ("Contains:", S.contains ("test", "es")) Whether to include True p ("Count:", S.count ("test", "T")) //string occurrences of characters 2 p ("Hasprefix:", S.hasprefix ("Test", "TE")) //judge the string header true p ("Hassuffix:", S.hassuffix ("Test", "St")) //determine the end of the string True p ("Index:", S.index ("test", "E") //query string position 1 p ("Join:", S.join ([]string{"a", "B"}, "-"))//string array connection A-B p ("Repeat:", S.repeat ("a", 5)) //repeats a string aaaaa p ("Replace:", S . Replace ("foo", "o", "0",-1)) //string substitution specifies that the starting position is less than 0, replacing all f00 p ("Replace:", S. Replace ("foo", "o", "0", 1)) //string substitution specifies the starting position 1 f0o p ("Split:", S.SPlit ("A-b-c-d-e", "-")) //string cut [a b c D e] p ("ToLower:", S.tolower ("TEST")) / /String Lowercase conversion test p ("ToUpper:", S.toupper ("Test")) //string capitalization conversion test P ("Len:", Len ("Hello")) //string length p ("Char:", "Hello" [1]) //the characters in the string, Type is byte}
394 Reads