Skip to content

Instantly share code, notes, and snippets.

@hehongwei44
Created July 6, 2014 02:46
Show Gist options
  • Save hehongwei44/3659b0c244aa0b56d265 to your computer and use it in GitHub Desktop.
Save hehongwei44/3659b0c244aa0b56d265 to your computer and use it in GitHub Desktop.
判断是否是合理的IP地址
/**
*
* @descrition:判断是否是合理的IP地址
* @param:str->待验证的IP地址
* @return :true合理的IP地址
*
*/
var isIP = function (str) {
var pattern = /^(?:(?: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]?)$/;
return pattern.test(str);
}
@hehongwei44
Copy link
Author

验证的形式如:192.168.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment