Golang Note--string

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

In any language, the string manipulation API is very important, some or memorize better, of course, if you can not remember to see the source file, you have to say that the go language source looks very comfortable.

The API for string manipulation is mostly encapsulated in the strings package, which lists some common

Func Count (S, Sep string) int

Gets the number of specified substrings

Func Contains (S, substr string) bool

Determine if a substring is included

Func Containsany (S, chars string) bool

Determines whether to include any one character in a string, and returns True if any of the characters are included

Func Equalfold (S, t string) bool

When case is ignored, determine whether two strings are equal.

Func fields (s string) []string

is actually the Splite function in other languages, separating the strings, this is separated by a space.

Func Split (S, Sep string) []string

Separates strings by specified characters

Func Fieldsfunc (S string, F func (rune) bool) []string

More powerful custom delimited strings, using functions as arguments

    " a,b,c d,e,f "     Slice1:bool  {        if','' ' {            returntrue        }        returnfalse     })    Print_array (Slice1)

Func Hasprefix (s, prefix string) bool

Determine whether to start with a string

Func hassuffix (s, suffix string) bool

Determine whether to end with a string

  

Join this look at the source bar http://www.widuu.com/archives/01/939.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.