記錄一下
func isNumber(s string) bool {
pattern := `^\d+(\.\d+)?$`
match, err := regexp.MatchString(pattern, s)
if err != nil {
return false
}
return match
}
func isRomanNumber(s string) bool {
re := regexp.MustCompile("^[IVXLCDM]*$")
return re.MatchString(s)
}
func isURL(s string) bool {
regex := regexp.MustCompile(`^(http://|https://)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$`)
return regex.MatchString(s)
}
func isEmail(s string) bool {
emailRegex := regexp.MustCompile(`^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$`)
return emailRegex.MatchString(s)
}
func isNotUnicode(s string) bool {
regex := `^[^\p{L}\p{N}]*$`
match, _ := regexp.MatchString(regex, s)
return match
}