lsstring

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertString

func ConvertString(src string, srcCharset string, tagCharset string) string

ConvertString 字符串编码转换 从srcCharset -> tagCharset。比如 s := ConvertString(s, "gbk", "utf-8")

func DecodeTextToUTF8

func DecodeTextToUTF8(filename string) (string, error)

DecodeTextToUTF8 test charset of text file and decode non-utf8 to utf8

func DeleteInvisibleCh added in v0.0.8

func DeleteInvisibleCh(str string) string

DeleteInvisibleCh 删除不可见字符

func DetectTextFileCharset

func DetectTextFileCharset(filename string) (string, error)

DetectTextFileCharset to detext the char set of text files

func FindIPStrings added in v0.0.8

func FindIPStrings(src string) ([]string, bool)

FindIPStrings 根据正则表达是找出所有匹配IP串

func FindStringWithRegexp added in v0.0.8

func FindStringWithRegexp(src string, regstr string) ([]string, bool)

FindStringWithRegexp 根据正则表达是找出所有匹配串

func FirstToLower added in v0.0.8

func FirstToLower(s string) string

FirstToLower 字符串首字母小写

func FirstToUpper added in v0.0.8

func FirstToUpper(s string) string

FirstToUpper 字符串首字母大写

func GBKToUTF8

func GBKToUTF8(s []byte) ([]byte, error)

GBKToUTF8 将数据从BGK转换成UTF8 from bgk to utf8 encoding conversion

func GBKToUTF8Str

func GBKToUTF8Str(str string) (string, error)

GBKToUTF8Str 字符串编码 gbk到utf8转换

func GetStringBetween

func GetStringBetween(str, start, end string) string

GetStringBetween 获取两个子串之间的内容这个函数GetStringBetween接受三个参数:一个主字符串str,一个起始子串start和一个结束子串end。函数首先查找起始子串和结束子串在主字符串中的位置,然后返回它们之间的内容。如果任一子串未找到,函数返回空字符串。

func GuessCharset

func GuessCharset(src string) (string, error)

GuessCharset 猜输入字符串最有可能的编码集

func IsAlphaNumberOnly added in v0.0.8

func IsAlphaNumberOnly(str string) bool

IsAlphaNumberOnly 判断数字和26字母组成的串

func IsAlphaNumberUnderlineOnly added in v0.0.8

func IsAlphaNumberUnderlineOnly(str string) bool

IsAlphaNumberUnderlineOnly 判断数字、下划线和26字母组成的串

func IsAlphaOnly added in v0.0.8

func IsAlphaOnly(str string) bool

IsAlphaOnly 判断26个字母组成的串

func IsChinaMobile added in v0.0.8

func IsChinaMobile(b []byte) bool

IsChinaMobile 检验是否为合法的中国手机号, 不是那么太精细 只要是 13,14,15,18 开头的 11 位数字就认为是中国手机号

func IsChinaMobileString added in v0.0.8

func IsChinaMobileString(str string) bool

IsChinaMobileString 同 func IsChinaMobile(b []byte) bool

func IsChineseChar added in v0.0.8

func IsChineseChar(str string) bool

IsChineseChar 判断中文串

func IsChineseString added in v0.0.8

func IsChineseString(str string) bool

IsChineseString 判断全中文字符串

func IsGBKData

func IsGBKData(data []byte) bool

IsGBKData 判断数据是否是gbk编码

func IsGBKStr

func IsGBKStr(str string) bool

IsGBKStr 判断字符串是否是gbk编码

func IsIPAddress added in v0.0.8

func IsIPAddress(b []byte) bool

IsIPAddress validate ipv4 address

func IsIPAddressString added in v0.0.8

func IsIPAddressString(str string) bool

IsIPAddressString 同 func IsIPAddress(b []byte) bool

func IsLowerCaseOnly added in v0.0.8

func IsLowerCaseOnly(str string) bool

IsLowerCaseOnly 判断只有小写字母组成的串

func IsMail added in v0.0.8

func IsMail(b []byte) bool

IsMail 检验是否为合法的电子邮箱, 考虑到各个网站的 mail 要求不一样, 这里匹配比较宽松 邮箱用户名可以包含 0-9, A-Z, a-z, -, _, . 开头字母不能是 -, _, . 结尾字母不能是 -, _, . -, _, . 这三个连接字母任意两个不能连续, 如不能出现 --, __, .., -_, -., _. 邮箱的域名可以包含 0-9, A-Z, a-z, - 连接字符 - 只能出现在中间, 不能连续, 如不能 -- 支持多级域名, x@y.z, x@y.z.w, x@x.y.z.w.e

func IsMailString added in v0.0.8

func IsMailString(str string) bool

IsMailString 同 func IsMail(b []byte) bool

func IsNickname added in v0.0.8

func IsNickname(b []byte) bool

IsNickname 检验是否为合法的昵称, 合法的字符有 0-9, A-Z, a-z, _, 汉字 字符 '_' 只能出现在中间且不能重复, 如 "__"

func IsNicknameString added in v0.0.8

func IsNicknameString(str string) bool

IsNicknameString 同 func IsNickname(b []byte) bool

func IsNumberOnly added in v0.0.8

func IsNumberOnly(str string) bool

IsNumberOnly 判断只有数字组成的串

func IsUTF8Str

func IsUTF8Str(str string) bool

IsUTF8Str 判断字符串是不是UTF8编码

func IsUpperCaseOnly added in v0.0.8

func IsUpperCaseOnly(str string) bool

IsUpperCaseOnly 判断只有大写字母组成的穿

func IsUserName added in v0.0.8

func IsUserName(b []byte) bool

IsUserName 检验是否为合法的用户名, 合法的字符有 0-9, A-Z, a-z, _ 第一个字母不能为 _, 0-9 最后一个字母不能为 _, 且 _ 不能连续

func IsUserNameString added in v0.0.8

func IsUserNameString(str string) bool

IsUserNameString 同 func IsName(b []byte) bool

func RemoveInvisibleChars

func RemoveInvisibleChars(input string) string

RemoveInvisibleChars 删除不可见字符

func UTF8ToGBK

func UTF8ToGBK(s []byte) ([]byte, error)

UTF8ToGBK utf8 to gbk encoding conversion

func UTF8ToGBKStr

func UTF8ToGBKStr(str string) (string, error)

UTF8ToGBKStr 字符串编码 utf8到gbk转换

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL