2021-07-30 22:30:27 +08:00
|
|
|
package re
|
|
|
|
|
2022-06-29 17:00:34 +08:00
|
|
|
import (
|
|
|
|
"regexp"
|
|
|
|
"strings"
|
|
|
|
)
|
2021-07-30 22:30:27 +08:00
|
|
|
|
|
|
|
var (
|
2021-10-26 13:17:33 +08:00
|
|
|
DomainRe = regexp.MustCompile(`([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.)+([a-zA-Z][-a-zA-Z]{0,62})`)
|
2021-07-30 22:30:27 +08:00
|
|
|
|
|
|
|
IPv4Re = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)
|
2024-12-30 14:04:06 +08:00
|
|
|
IPv6Re = regexp.MustCompile(`fe80:(:[0-9a-fA-F]{1,4}){0,4}(%\w+)?|([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|64:ff9b::(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|::[fF]{4}:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?`)
|
2021-07-30 22:30:27 +08:00
|
|
|
)
|
2022-06-29 17:00:34 +08:00
|
|
|
|
|
|
|
func MaybeRegexp(s string) bool {
|
|
|
|
return strings.ContainsAny(s, "[]{}()?")
|
|
|
|
}
|