PHPIPV6 regular expression verification code. Copy the code as follows :? PhpliterallyfromtheABNFinrfc3986 (thankstoWCP) functionvalidateIPv6 ($ IP) {returnpreg_match ((? :(? :(? : [A-f0-9] {} :) {6 }::(? : [A-f0
The code is as follows:
// Literally from the ABNF in rfc3986 (thanks to 'wcp ')
Function validateIPv6 ($ IP)
{
Return preg_match ('/\
(? :
(? :
(? : [A-f0-9] {} :) {6}
::(? : [A-f0-9] {} :) {5}
(? : [A-f0-9 })? ::(? : [A-f0-9] {} :) {4}
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? ::(? : [A-f0-9] {} :) {3}
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? ::(? : [A-f0-9] {} :) {2}
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? : [A-f0-9 }:
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? ::
)
(? :
[A-f0-9] {}: [a-f0-9}
(? :(? : [0-9] | [1-9] [0-9] | 1 [0-9] [0-9] | 2 [0-4] [0-9] | 25 [0-5]) \.) {3}
(? : [0-9] | [1-9] [0-9] | 1 [0-9] [0-9] | 2 [0-4] [0-9] | 25 [0-5])
)
(? :
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? : [A-f0-9}
(? :(? : [A-f0-9] {} :) {} [a-f0-9 })? ::
)
) \ Z/ix ',
$ IP
);
}
?>
The http://www.bkjia.com/PHPjc/321275.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321275.htmlTechArticle code is as follows :? Php // literally from the ABNF in rfc3986 (thanks to 'wcp') function validateIPv6 ($ IP) {return preg_match ('/\ (? :(? :(? : [A-f0-9] {} :) {6 }::(? : [A-f0...