# Functions
AppendIfMissing 如果给定字符串不是以给定的字符串为结尾,则在"尾部"添加结尾字符串(不忽略大小写).
No description provided by the author
No description provided by the author
No description provided by the author
BytesToString converts byte slice to string without a memory allocation.
ContainsIgnoreCase 是否包含(不区分大小写)
e.g.
EmptyToDefault
@param trimArgs 是否先对 传参str 进行trim处理?(默认:false,不处理)
*/.
Equals 字符串是否相等?(区分大小写)
PS: 也可以用 == 进行判断字符串是否相等(但不建议这么干).
GetChineseRuneCount 获取字符串中 中文字符 的个数
PS: 包括简体、繁体.
GetRuneCount
PS:
(1) 包括简体、繁体.
HasChineseRune 字符串中是否存在 中文字符?
PS: 包括简体、繁体.
No description provided by the author
No description provided by the author
No description provided by the author
IsBlank
(" \r\n ") => true
*/.
IsEmpty strings.Compare比自建方法“==”的速度要快
PS: 由于此方法被调用的频率较高,因此方法体内禁止调用自己写的方法,全用原生的.
No description provided by the author
No description provided by the author
PrependIfMissing 如果给定字符串不是以给定的字符串为开头,则在"首部"添加 起始字符串.
RemoveSpace 移除str中所有的(包括左右的、中间的):" "、"\t"、"\r"、"\n"..
ReplaceSpacesWithSpace 将连续的空格替换为单个空格
e.g.
No description provided by the author
StringToBytes converts string to byte slice without a memory allocation.
SubAfter
@param index 包括
@return 范围: [index, length)
*/.
SubAfterString
case 1: s包含str的情况,返回截取后的字符串;
case 2: s不包含str的情况,直接返回s.
SubBefore
@param index 不包括
@return 范围: [0, index)
*/.
SubBeforeString
case 1: s包含str的情况,返回截取后的字符串;
case 2: s不包含str的情况,直接返回s.
Substring Return part of a string.
# Variables
Compare 字符串比较
@return (1) -1: if a < b
(2) 0: if a == b
(3) +1: if a > b
*/.
Contains 是否包含(区分大小写)
e.g.
Count 计数
@return >= 0
e.g.
CutPrefix
e.g.
No description provided by the author
Elipse 将字符串截断为指定长度,并在截断后附加省略号.
EndWith
PS: 区分大小写.
EqualsIgnoreCase 字符串是否相等?(不区分大小写)
e.g.
Format 格式化文本,类似Java的"StrUtil.format".
Index
PS:
(1) s中不存在substr的话,返回 -1
(2) s中存在多个substr的话,返回 第一个的下标
@param s 被查找的字符串
@param str 查找的字符串
e.g.
IntToString int(10进制) => string
PS: strconv.Itoa(i) <=> FormatInt(int64(i), 10)
*/.
IntToStringWithBase int(各种进制) => string
@param base 传参i的进制数
*/.
No description provided by the author
LastIndex
e.g.
RemovePrefixIfExists 去掉指定的"前缀"(如果存在的话)
PS:
(1) 区分大小写;
(2) 存在多个的话,只会移除第1个.
RemoveSuffixIfExists 去掉指定的"后缀"(如果存在的话)
PS:
(1) 区分大小写;
(2) 存在多个的话,只会移除最后1个.
No description provided by the author
ReplaceAll
e.g.
Split
@param sep 可以为"",此种情况比较特殊,详见下例;
如果s中不存在sep,那么返回切片的长度为1
@return 必定不为nil && len >= 1
e.g.
StartWith
PS: 区分大小写.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trim 返回字符串,删除了s"左边&&右边"的连续cutset.
TrimFunc 返回字符串,删除了s"左边&&右边"的连续的满足条件的rune.
TrimLeft 返回字符串,删除了s"左边"的连续cutset.
TrimLeftFunc 返回字符串,删除了s"左边"的连续的满足条件的rune.
TrimRight 返回字符串,删除了s"右边"的连续cutset.
TrimRightFunc 返回字符串,删除了s"右边"的连续的满足条件的rune.
TrimSpace 去掉左右的空格(包括:\r、\n),不包括中间的空格.