Golang--string operation

Source: Internet
Author: User
Tags join split
string to int
int, err: = StrConv. Atoi (String) string to Int64
Int64, err: = String. parseint (String, ten, max) int to string
String: = StrConv. Itoa (int) Int64 to string
String: = StrConv. Formatint (Int64, Hasprefix) determines whether the string s starts with prefix
Strings. Hasprefix (s, prefix string) bool Hassuffix determines whether the string s ends at suffix
Strings. Hassuffix (s, suffix string) bool contains determines whether the string s contains substr
Strings. Contains (S, substr string) bool Index returns the index of the string str in the string s (index of the first character of str), 1 indicates that the string s does not contain a string str
Strings. Index (S, str string) int lastindex Returns the position of the last occurrence of the string str in the string s
Strings. LastIndex (S, str string) int non-ASCII encoded character positioning
Strings. Indexrune (s string, ch int) Replace replaces the first n strings in str with the string new, and if 1 replaces all strings old as new
Strings. Replace (str, old, new, N) string count is used to calculate the number of non-overlapping occurrences of STR in S
Strings. Count (S, str string) int repeat is used to repeat count string s and return a new string
Strings. Repeat (s, Count int) string ToLower converts all Unicode characters in a string to lowercase letters
Strings. ToLower (s) string ToUpper converts all Unicode characters in a string to uppercase letters
Strings. ToUpper (s) string trimspace culling whitespace at the beginning and end of a string trim culling the beginning and end of a string trimleft,trimright culling the beginning or ending string Fields use one or more whitespace symbols to split a string as a delimiter of dynamic length, returning slice
Strings. Fields (s) slice split split the specified string with a custom split symbol
Strings. Split (s, Sep) Slice join is used to stitch a string into a slice using a split symbol for element type string
Strings. Join (SL []string, Sep string)

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.