最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Go 標(biāo)準(zhǔn)包 strings 學(xué)習(xí)(4)EqualFold,Fields,FieldsFunc

2023-04-28 13:16 作者:取悅疾風(fēng)  | 我要投稿

官網(wǎng)

https://pkg.go.dev/strings@go1.20.3


func?EqualFold

EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under simple Unicode case-folding, which is a more general form of case-insensitivity.

翻譯

EqualFold報告解釋為UTF-8字符串的s和t在簡單的Unicode大小寫折疊下是否相等,這是一種更通用的大小寫不敏感形式。

例子

理解:

就是不區(qū)分大小寫的equal

func?Fields

Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.

翻譯

Fields圍繞一個或多個連續(xù)空格字符的每個實例拆分字符串s,這是由unicode定義的。IsSpace,返回s的子字符串切片,如果s只包含空白則返回空切片。

例子

輸出:

Fields are: ["foo" "bar" "baz"]

理解:

將字符串按照空格分割,并放入一個切片中

func?FieldsFunc

FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the string is empty, an empty slice is returned.


FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.


翻譯

FieldsFunc在每次運行滿足f(c)的Unicode代碼點c時拆分字符串s,并返回s的切片數(shù)組。如果s中的所有代碼點都滿足f(c)或字符串為空,則返回空切片。

FieldsFunc不保證調(diào)用f(c)的順序,并假設(shè)對于給定的c, f總是返回相同的值。

案例:

輸出

Fields are: ["foo1" "bar2" "baz3"]

理解

f就是要自定義的一個規(guī)則

然后調(diào)用FieldsFunc,傳入需要分割的字符串,再傳入規(guī)則f,即可獲取分割后的字符串切片

結(jié)合上一個方法看,就是這個方法允許自定義分割的規(guī)則,上一個方法是通過空格分割的

Go 標(biāo)準(zhǔn)包 strings 學(xué)習(xí)(4)EqualFold,Fields,FieldsFunc的評論 (共 條)

使用qq登录你需要登录后才可以评论。
保山市| 南昌市| 宣化县| 莱芜市| 遂平县| 紫阳县| 巍山| 繁峙县| 太原市| 新绛县| 三穗县| 罗田县| 霍邱县| 宁远县| 珲春市| 新蔡县| 平顶山市| 黑河市| 红原县| 西城区| 武隆县| 南木林县| 江西省| 闽侯县| 东莞市| 汶川县| 永胜县| 梓潼县| 杭锦旗| 遵化市| 滦平县| 卢龙县| 弥渡县| 江西省| 沙田区| 隆林| 柳江县| 汤原县| 车险| 陆良县| 开阳县|