Documentation ¶
Index ¶
- Variables
- func ContainLower(str string) bool
- func ContainUpper(str string) bool
- func IsASCII(str string) bool
- func IsAllLower(str string) bool
- func IsAllUpper(str string) bool
- func IsEmptyString(str string) bool
- func IsFloat(v any) bool
- func IsFloatStr(str string) bool
- func IsInt(v any) bool
- func IsIntStr(str string) bool
- func IsIp(ipstr string) bool
- func IsIpV4(ipstr string) bool
- func IsIpV6(ipstr string) bool
- func IsJSON(str string) bool
- func IsNumber(v any) bool
- func IsNumberStr(s string) bool
- func IsPort(str string) bool
- func IsPrintable(str string) bool
- func IsRegexMatch(str, regex string) bool
- func IsStrongPassword(password string, length int) bool
- func IsUrl(str string) bool
- func IsWeakPassword(password string) bool
- func RegexMatch(str string, regex *regexp.Regexp) bool
Constants ¶
This section is empty.
Variables ¶
var ( AlphaMatcher = regexp.MustCompile(`^[a-zA-Z]+$`) LetterRegexMatcher = regexp.MustCompile(`[a-zA-Z]`) NumberRegexMatcher = regexp.MustCompile(`\d`) IntStrMatcher = regexp.MustCompile(`^[\+-]?\d+$`) UrlMatcher = regexp.MustCompile(`^((ftp|http|https?):\/\/)?(\S+(:\S*)?@)?((([1-9]\d?|1\d\d|2[01]\d|22[0-3])(\.(1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(([a-zA-Z0-9]+([-\.][a-zA-Z0-9]+)*)|((www\.)?))?(([a-z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-z\x{00a1}-\x{ffff}]{2,}))?))(:(\d{1,5}))?((\/|\?|#)[^\s]*)?$`) DnsMatcher = regexp.MustCompile(`^[a-zA-Z]([a-zA-Z0-9\-]+[\.]?)*[a-zA-Z0-9]$`) EmailMatcher = regexp.MustCompile(`\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`) ChineseMobileMatcher = regexp.MustCompile(`^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$`) ChineseIdMatcher = regexp.MustCompile(`^[1-9]\d{5}(18|19|20|21|22)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$`) ChineseMatcher = regexp.MustCompile("[\u4e00-\u9fa5]") ChinesePhoneMatcher = regexp.MustCompile(`\d{3}-\d{8}|\d{4}-\d{7}|\d{4}-\d{8}`) CreditCardMatcher = regexp.MustCompile(`^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27][0-9]{14})$`) Base64Matcher = regexp.MustCompile(`^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$`) )
Functions ¶
func ContainLower ¶
ContainLower check if the string contain at least one lower case letter a-z. Play: https://go.dev/play/p/Srqi1ItvnAA
func ContainUpper ¶
ContainUpper check if the string contain at least one upper case letter A-Z. Play: https://go.dev/play/p/CmWeBEk27-z
func IsASCII ¶
IsASCII checks if string is all ASCII char. Play: https://go.dev/play/p/hfQNPLX0jNa
func IsAllLower ¶
IsAllLower check if the string is all lower case letters a-z. Play: https://go.dev/play/p/GjqCnOfV6cM
func IsAllUpper ¶
IsAllUpper check if the string is all upper case letters A-Z. Play: https://go.dev/play/p/ZHctgeK1n4Z
func IsEmptyString ¶
IsEmptyString check if the string is empty. Play: https://go.dev/play/p/dpzgUjFnBCX
func IsFloat ¶
IsFloat check if the value is float(float32, float34) or not. Play: https://go.dev/play/p/vsyG-sxr99_Z
func IsFloatStr ¶
IsFloatStr check if the string can convert to a float. Play: https://go.dev/play/p/LOYwS_Oyl7U
func IsInt ¶
IsInt check if the value is integer(int, unit) or not. Play: https://go.dev/play/p/eFoIHbgzl-z
func IsIntStr ¶
IsIntStr check if the string can convert to a integer. Play: https://go.dev/play/p/jQRtFv-a0Rk
func IsIp ¶
IsIp check if the string is a ip address. Play: https://go.dev/play/p/FgcplDvmxoD
func IsIpV4 ¶
IsIpV4 check if the string is a ipv4 address. Play: https://go.dev/play/p/zBGT99EjaIu
func IsIpV6 ¶
IsIpV6 check if the string is a ipv6 address. Play: https://go.dev/play/p/AHA0r0AzIdC
func IsJSON ¶
IsJSON checks if the string is valid JSON. Play: https://go.dev/play/p/8Kip1Itjiil
func IsNumber ¶
IsNumber check if the value is number(integer, float) or not. Play: https://go.dev/play/p/mdJHOAvtsvF
func IsNumberStr ¶
IsNumberStr check if the string can convert to a number. Play: https://go.dev/play/p/LzaKocSV79u
func IsPrintable ¶
IsPrintable checks if string is all printable chars. Play: https://go.dev/play/p/Pe1FE2gdtTP
func IsRegexMatch ¶
IsRegexMatch check if the string match the regexp. Play: https://go.dev/play/p/z_XeZo_litG
func IsStrongPassword ¶
IsStrongPassword check if the string is strong password, if len(password) is less than the length param, return false Strong password: alpha(lower+upper) + number + special chars(!@#$%^&*()?><). Play: https://go.dev/play/p/QHdVcSQ3uDg
func IsUrl ¶
IsUrl check if the string is url. Play: https://go.dev/play/p/pbJGa7F98Ka
func IsWeakPassword ¶
IsWeakPassword check if the string is weak password Weak password: only letter or only number or letter + number. Play: https://go.dev/play/p/wqakscZH5gH
Types ¶
This section is empty.