Skip to content

Instantly share code, notes, and snippets.

@thefury
Created August 21, 2021 19:41
Show Gist options
  • Select an option

  • Save thefury/79a9f147482090371c0aaf8807087dd8 to your computer and use it in GitHub Desktop.

Select an option

Save thefury/79a9f147482090371c0aaf8807087dd8 to your computer and use it in GitHub Desktop.
Simple ruby IP check
def valid?(ip)
rgx=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
ip.match(rgx) != nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment