Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "regexp"
- )
- var ipRegex = regexp.MustCompile("((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))")
- func getRemoteIp(ip string) string {
- groups := ipRegex.FindAllString(ip, -1)
- if len(groups) > 0 {
- ip = groups[0]
- }
- return ip
- }
- func main() {
- ip1 := "%以太网%10.12.90.233%以太网:22334"
- ip1 = getRemoteIp(ip1)
- fmt.Printf("%s\n", ip1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement