Created
July 6, 2014 02:46
-
-
Save hehongwei44/3659b0c244aa0b56d265 to your computer and use it in GitHub Desktop.
判断是否是合理的IP地址
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
验证的形式如:192.168.1.1