feat:完善项目
This commit is contained in:
34
utils/regexp.go
Normal file
34
utils/regexp.go
Normal file
@ -0,0 +1,34 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func ValidateMobile(mobile string) bool {
|
||||
reg := regexp.MustCompile("^1[3|4|5|6|7|8|9][0-9]\\d{8}$")
|
||||
return reg.MatchString(mobile)
|
||||
}
|
||||
|
||||
func ValidateEmail(email string) bool {
|
||||
reg := regexp.MustCompile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$")
|
||||
return reg.MatchString(email)
|
||||
}
|
||||
|
||||
func ValidateUrl(url string) {
|
||||
//reg := regexp.MustCompile("^([hH][tT]{2}[pP]:|||[hH][tT]{2}[pP][sS]:|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$")
|
||||
}
|
||||
|
||||
func ValidateCompile(obj, compile string) bool {
|
||||
reg := regexp.MustCompile(compile)
|
||||
return reg.MatchString(obj)
|
||||
}
|
||||
|
||||
func ReplaceAllCompile(obj, compile, replace string) string {
|
||||
reg := regexp.MustCompile(compile)
|
||||
return reg.ReplaceAllString(obj, replace)
|
||||
}
|
||||
|
||||
func MatchString(pattern string, s string) bool {
|
||||
status, _ := regexp.MatchString(pattern, s)
|
||||
return status
|
||||
}
|
Reference in New Issue
Block a user