Documentation
¶
Index ¶
- Constants
- func ClearWordRankCache()
- func ExtractRegexMatch(regex, content string, index int) (string, error)
- func FirstToLower(str string) string
- func FirstToUpper(str string) string
- func GetRootDomain(url string) string
- func HumpName(name string) string
- func InStringArray(needle string, haystack []string) bool
- func IsFloat(s string) bool
- func IsInt(s string) bool
- 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 SubString(str string, start, end 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 ClearWordRankCache ¶ added in v0.0.3
func ClearWordRankCache()
ClearWordRankCache 清除 WordRank 函数的缓存
func ExtractRegexMatch ¶ added in v0.0.3
ExtractRegexMatch 提取正则表达式匹配的指定捕获组 参数:
- regex: 正则表达式字符串
- content: 要匹配的内容
- index: 捕获组索引
返回值:匹配的字符串和可能的错误
func InStringArray ¶ added in v0.0.3
InStringArray 检查字符串是否在切片中 参数:
- needle: 要查找的字符串
- haystack: 字符串切片
返回值:如果找到返回true,否则返回false
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 SubString ¶ added in v0.0.3
SubString 截取字符串 参数:
- str: 输入字符串
- start: 起始位置
- end: 结束位置(如果为-1,则截取到字符串末尾)
返回值:截取后的字符串
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)