Go String

16 functions

strings.Containsstrings.Contains(s, substr string) bool

Reports whether substr is within s.

strings.HasPrefixstrings.HasPrefix(s, prefix string) bool

Reports whether s begins with prefix.

strings.HasSuffixstrings.HasSuffix(s, suffix string) bool

Reports whether s ends with suffix.

strings.Indexstrings.Index(s, substr string) int

Returns the index of the first instance of substr in s, or -1.

strings.Countstrings.Count(s, substr string) int

Counts the number of non-overlapping instances of substr in s.

strings.Replacestrings.Replace(s, old, new string, n int) string

Returns a copy of s with the first n occurrences of old replaced by new.

strings.ReplaceAllstrings.ReplaceAll(s, old, new string) string

Returns a copy of s with all occurrences of old replaced by new.

strings.Splitstrings.Split(s, sep string) []string

Slices s into all substrings separated by sep.

strings.Joinstrings.Join(elems []string, sep string) string

Concatenates the elements of elems to create a single string separated by sep.

strings.ToLowerstrings.ToLower(s string) string

Returns s with all Unicode letters mapped to their lower case.

strings.ToUpperstrings.ToUpper(s string) string

Returns s with all Unicode letters mapped to their upper case.

strings.TrimSpacestrings.TrimSpace(s string) string

Returns a slice of s with all leading and trailing white space removed.

strings.Trimstrings.Trim(s, cutset string) string

Returns a slice of s with all leading and trailing cutset characters removed.

strings.Fieldsstrings.Fields(s string) []string

Splits s around each instance of whitespace and returns a slice of substrings.

strings.Repeatstrings.Repeat(s string, count int) string

Returns a new string consisting of count copies of s.

strings.ContainsAnystrings.ContainsAny(s, chars string) bool

Reports whether any Unicode code points in chars are within s.