Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "regexp"
  6. )
  7.  
  8. 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))))")
  9.  
  10. func getRemoteIp(ip string) string {
  11. groups := ipRegex.FindAllString(ip, -1)
  12. if len(groups) > 0 {
  13. ip = groups[0]
  14. }
  15. return ip
  16. }
  17.  
  18. func main() {
  19. ip1 := "%以太网%10.12.90.233%以太网:22334"
  20. ip1 = getRemoteIp(ip1)
  21. fmt.Printf("%s\n", ip1)
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement