Documentation
¶
Index ¶
- Constants
- func ChunkSplit(body string, chunkLen int, end string) string
- func ClearWordRankCache()
- func Explode(delimiter, str string) []string
- func ExtractRegexMatch(regex, content string, index int) (string, error)
- func Fields(str string) []string
- func FirstToLower(str string) string
- func FirstToUpper(str string) string
- func GetRootDomain(url string) string
- func HasPrefix(s, prefix string) bool
- func HasSuffix(s, suffix string) bool
- func HumpName(name string) string
- func Implode(glue string, pieces []string) string
- func InStringArray(needle string, haystack []string) bool
- func IsFloat(s string) bool
- func IsInt(s string) bool
- func IsSubDomain(subDomain, mainDomain string) bool
- func Join(array []string, sep string) string
- func JoinAny(array interface{}, sep string) string
- func Pos(haystack, needle string, startOffset ...int) int
- func PosI(haystack, needle string, startOffset ...int) int
- func PosIRune(haystack, needle string, startOffset ...int) int
- func PosR(haystack, needle string, startOffset ...int) int
- func PosRI(haystack, needle string, startOffset ...int) int
- func PosRIRune(haystack, needle string, startOffset ...int) int
- func PosRRune(haystack, needle string, startOffset ...int) int
- func PosRune(haystack, needle string, startOffset ...int) int
- func QuoteMeta(str string, chars ...string) string
- func Replace(origin, search, replace string, count ...int) string
- func ReplaceByArray(origin string, array []string) string
- func ReplaceByMap(origin string, replaces map[string]string) string
- func ReplaceI(origin, search, replace string, count ...int) string
- func ReplaceIByArray(origin string, array []string) string
- func ReplaceIByMap(origin string, replaces map[string]string) string
- func ReplaceIndex(s, old, new string, n int) string
- func ReplaceRegexMatch(regex, newStr, content string) (string, error)
- func ResolveAddress(addr []string) (string, error)
- func SetCacheDuration(duration time.Duration)
- func Split(str, delimiter string) []string
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func SubString(str string, start, end int) string
- func Trim(str string, characterMask ...string) string
- func TrimAll(str string, characterMask ...string) string
- func TrimLeft(str string, characterMask ...string) string
- func TrimLeftStr(str string, cut string, count ...int) string
- func TrimRight(str string, characterMask ...string) string
- func TrimRightStr(str string, cut string, count ...int) string
- func TrimStr(str string, cut string, count ...int) string
- func UnderLineName(name string) string
- type WordRankResult
- type WordRankResults
Constants ¶
const (
// NotFoundIndex is the position index for string not found in searching functions.
NotFoundIndex = -1
)
Variables ¶
This section is empty.
Functions ¶
func ChunkSplit ¶ added in v0.0.6
ChunkSplit splits a string into smaller chunks. Can be used to split a string into smaller chunks which is useful for e.g. converting BASE64 string output to match RFC 2045 semantics. It inserts end every chunkLen characters. It considers parameter `body` and `end` as unicode string.
func ClearWordRankCache ¶ added in v0.0.3
func ClearWordRankCache()
ClearWordRankCache 清除 WordRank 函数的缓存
func Explode ¶ added in v0.0.6
Explode splits string `str` by a string `delimiter`, to an array. See http://php.net/manual/en/function.explode.php.
func ExtractRegexMatch ¶ added in v0.0.3
ExtractRegexMatch 提取正则表达式匹配的指定捕获组 参数:
- regex: 正则表达式字符串
- content: 要匹配的内容
- index: 捕获组索引
返回值:匹配的字符串和可能的错误
func Implode ¶ added in v0.0.6
Implode joins array elements `pieces` with a string `glue`. http://php.net/manual/en/function.implode.php
func InStringArray ¶ added in v0.0.3
InStringArray 检查字符串是否在切片中 参数:
- needle: 要查找的字符串
- haystack: 字符串切片
返回值:如果找到返回true,否则返回false
func IsSubDomain ¶ added in v0.0.6
IsSubDomain 检查 subDomain 是否为 mainDomain 的子域名。 支持在 mainDomain 中使用 '*' 通配符。
func Join ¶ added in v0.0.6
Join concatenates the elements of `array` to create a single string. The separator string `sep` is placed between elements in the resulting string.
func JoinAny ¶ added in v0.0.6
JoinAny concatenates the elements of `array` to create a single string. The separator string `sep` is placed between elements in the resulting string.
The parameter `array` can be any type of slice, which be converted to string array.
func Pos ¶
Pos returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.
func PosI ¶
PosI returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.
func PosIRune ¶
PosIRune acts like function PosI but considers `haystack` and `needle` as unicode string.
func PosR ¶
PosR returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.
func PosRI ¶
PosRI returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.
func PosRIRune ¶
PosRIRune acts like function PosRI but considers `haystack` and `needle` as unicode string.
func PosRRune ¶
PosRRune acts like function PosR but considers `haystack` and `needle` as unicode string.
func PosRune ¶
PosRune acts like function Pos but considers `haystack` and `needle` as unicode string.
func QuoteMeta ¶
QuoteMeta returns a version of `str` with a backslash character (`\`). If custom chars `chars` not given, it uses default chars: .\+*?[^]($)
func Replace ¶
Replace returns a copy of the string `origin` in which string `search` replaced by `replace` case-sensitively.
func ReplaceByArray ¶
ReplaceByArray returns a copy of `origin`, which is replaced by a slice in order, case-sensitively.
func ReplaceByMap ¶
ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.
func ReplaceI ¶
ReplaceI returns a copy of the string `origin` in which string `search` replaced by `replace` case-insensitively.
func ReplaceIByArray ¶
ReplaceIByArray returns a copy of `origin`, which is replaced by a slice in order, case-insensitively.
func ReplaceIByMap ¶
ReplaceIByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-insensitively.
func ReplaceIndex ¶ added in v0.0.3
ReplaceIndex 替换字符串中第n次出现的旧字符串 参数:
- s: 原字符串
- old: 要替换的旧字符串
- new: 新字符串
- n: 第几次出现(从0开始)
返回值:替换后的字符串
func ReplaceRegexMatch ¶ added in v0.0.3
ReplaceRegexMatch 使用新字符串替换所有正则表达式匹配项 参数:
- regex: 正则表达式字符串
- newStr: 用于替换的新字符串
- content: 要处理的内容
返回值:替换后的字符串和可能的错误
func SetCacheDuration ¶ added in v0.0.3
SetCacheDuration 设置缓存的过期时间
func SplitAndTrim ¶ added in v0.0.6
SplitAndTrim splits string `str` by a string `delimiter` to an array, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.
func SubString ¶ added in v0.0.3
SubString 截取字符串 参数:
- str: 输入字符串
- start: 起始位置
- end: 结束位置(如果为-1,则截取到字符串末尾)
返回值:截取后的字符串
func TrimLeftStr ¶ added in v0.0.7
TrimLeftStr 从字符串的开头去除所有给定的 cut 字符串 注意:它不会去除开头的空白字符
func TrimRightStr ¶ added in v0.0.7
TrimRightStr 从字符串的结尾去除所有给定的 cut 字符串 注意:它不会去除结尾的空白字符
Types ¶
type WordRankResult ¶ added in v0.0.3
type WordRankResult struct {
Text string `json:"text"`
Count int `json:"count"`
Rank float32 `json:"rank"`
}
WordRankResult 表示单词频率分析的结果
type WordRankResults ¶ added in v0.0.3
type WordRankResults []WordRankResult
WordRankResults 是 WordRankResult 的切片,实现了 sort.Interface
func WordRank ¶ added in v0.0.3
func WordRank(arrWords []string) WordRankResults
WordRank 对输入的单词切片进行词频分析 参数:
- arrWords: 单词切片
返回值:按词频排序的 WordRankResults
func (WordRankResults) Len ¶ added in v0.0.3
func (s WordRankResults) Len() int
func (WordRankResults) Less ¶ added in v0.0.3
func (s WordRankResults) Less(i, j int) bool
func (WordRankResults) Swap ¶ added in v0.0.3
func (s WordRankResults) Swap(i, j int)