You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
414 B
25 lines
414 B
package regx
|
|
|
|
import (
|
|
"net"
|
|
"regexp"
|
|
)
|
|
|
|
func (rr *Regx) IsIp(address string) bool {
|
|
ip := net.ParseIP(address)
|
|
if ip != nil {
|
|
return true
|
|
}
|
|
return false
|
|
|
|
}
|
|
func (rr *Regx) IsIpRegx(address string) bool {
|
|
ipReg := `^((0|[1-9]\d?|1\d\d|2[0-4]\d|25[0-5])\.){3}(0|[1-9]\d?|1\d\d|2[0-4]\d|25[0-5])$`
|
|
r, _ := regexp.Compile(ipReg)
|
|
match := r.MatchString(address)
|
|
if match {
|
|
return true
|
|
}
|
|
return false
|
|
}
|