Skip to content

Instantly share code, notes, and snippets.

@egulhan
Created November 4, 2013 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egulhan/7301600 to your computer and use it in GitHub Desktop.
Save egulhan/7301600 to your computer and use it in GitHub Desktop.
IPv4 block IP PHP regex pattern
$patt='/^([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]){1}(\.|\.[1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]){0,3}$/';
/**
* Valid IP address examples:
*
* 192.168.1.1
* 192.168.
* 192.168
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment