Golang package Finishing (strings)

Source: Internet
Author: User
Tags uppercase character
This is a creation in Article, where the information may have evolved or changed.
/*package strings*///hasprefix  determines whether the string  s  starts with  prefix  strings. Hasprefix (s, prefix string)  bool//HasSuffix  Judging string  s  whether to  suffix  End strings. Hassuffix (s, suffix string)  bool//Contains  determine if string  s  contains  substrstrings. Contains (s, substr string)  bool//**** determines where the substring or character appears in the parent string (index) ***////index  return string  str   Index in String  s  (the index of the first character of str ),-1  represents a string  s  does not contain a string  strstrings. Index (s, str string)  int//LastIndex  return string  str  last occurrence in string  s  (str The index of the first character of the  ),-1  represents the string  s  does not contain the word//     character string  strstrings. LastIndex (s, str string)  int//If  ch  is a non- ASCII  encoded character, we recommend that you use the following function to position the character strings. Indexrune (S string, ch int)  int//******************************************************/// /****** string substitution ***********///replace  used to string the first &nbsp in  str ;n  string  old  Replace with string  new and returns a new string if  n = -1  replaces//      All strings  old  for string  newstrings. Replace (str, old, new, n)  string//*************************///******* count string occurrences ****/count   used to calculate string  str  non-overlapping number of occurrences in string  s  strings. Count (s, str string)  int//**************************///******** repeating string *************///repeat   Used to repeat  count  string  s  and return a new string strings. Repeat (s, count int)  string//****************************///******************* Modify string Casing ******** tolower  converts all  Unicode  characters in a string to the corresponding lowercase character strings. ToLower (s)  string//ToUpper  converts all  Unicode  characters in a string to the corresponding uppercase character strings. ToUpper (s)  string//********************* trim string ***     You can use  strings. Trimspace (s)   to remove whitespace from the beginning and end of the string, or strings if you want to reject the specified character. Trim (s,  "cut")   to remove the start and end  cut . The second argument of the function can contain any character, and if you want to exclude only the beginning or end of the string, you can make theUse  TrimLeft  or  TrimRight  to achieve     *********/    //*** Splits the string     strings. Fields (s)   will use  1  or multiple white space symbols to divide the string into small chunks as a dynamic-length delimiter, and return a  slice that returns a length of  0 if the string contains only whitespace symbols The  slice of  .     strings. Split (S, SEP)   for custom split symbols to split the specified string, returning  slice as well. Because this  2  function will return  slice, it is customary to use the  for-range  loop to process it     *************** **/        //*********** stitching  slice  to String ***///join  Used to stitch together a string strings.join the element type  string   slice  using a split symbol (sl []string, sep  String) **********************///************** reads the contents      function  strings from the string. Newreader (str)   is used to generate a  Reader  and read the contents of a string, and then returns a pointer to that  Reader , a function that reads content from other types, and:     read ()   read content from  []byte .     readbyte ()   and  readrune()   Read the next  byte  or  rune    **************/from the string 




Related Article

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.