Common string manipulation functions golang--

(1)func HasPrefix(s, prefix string) bool

Determining whether a prefix string string s prefix;

(2)func HasSuffix(s, suffix string) bool

Determining whether there is a suffix string s suffix string;

(3)func Contains(s, substr string) bool

Determining whether the character string contains the substring s substr;

(4)func Count(s, sep string) int

Returns a string will not be repeated a few sep s substring;

(5)func Index(s, sep string) int

Returns the string s neutron sep first occurrence of the string; -1 does not exist;

(6)func ToLower(s string) string

Returns a copy of string s small letter;

(7)func ToUpper(s string) string

S turn returns the string copy uppercase;

(8)func Repeat(s string, count int) string

Returns the count of the string of series string s;

(9)func Replace(s, old, new string, n int) string

S n before returning the string will not repeat old to new replacement string substring new sub-string; n <0 substring replace all old;

(10)func Trim(s string, cutset string) string

Returns the string s front end to remove all substrings strings cutset;

(11)func TrimSpace(s string) string

Returns the string s before and after removing the end blank characters (unicode.IsSpace specified) of the string;

(12)func TrimLeft(s string, cutset string) string

Returns the string s distal remove all substrings strings cutset;

(13)func TrimRight(s string, cutset string) string

Returns the string s to remove the rear end of the string cutset all substrings;

(14)func TrimPrefix(s, prefix string) string

Returns the string s to remove the prefix string prefix substring;

(15)func TrimSuffix(s, suffix string) string

Returns the string s removed for suffix string substring;

(16)func Fields(s string) []string

Returns the string s with one or more blank ( a plurality of strings slices unicode.IsSpace) character segmentation; blank or empty string returns an empty string sections;

(17)func Split(s, sep string) []string

Returns a string by the string s slice is a substring sep divided; sep when an empty string, the string s is divided into sections each of yard unicode value;

(18)func Join(a []string, sep string) string

Returns a string to the string sections connected sep substring;

(19)func NewReader(s string) *Reader

Reader create a reading pointer data from a string S;

Guess you like

Origin www.cnblogs.com/dzhy/p/10936366.html