Skip to content

Instantly share code, notes, and snippets.

@nenadg
Created May 29, 2014 13:37
Show Gist options
  • Save nenadg/42d65a770ac1e053f9a5 to your computer and use it in GitHub Desktop.
Save nenadg/42d65a770ac1e053f9a5 to your computer and use it in GitHub Desktop.
Regex that matches IPs excluding local addresses
^(?!(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^0\.))(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment