Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(?<IPv6>(?# 6{ h16 ":" } ls32 )((?<IPv6_1_R_H16>[0-9a-f]{4,4})\:){6,6}(?<IPV6_1_R_LS32>((?<IPV6_1_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_1_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_1_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_1_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# "::" 5{ h16 ":" } ls32 )\:\:((?<IPV6_2_R_H16>[0-9a-f]{4,4})\:){5,5}(?<IPV6_2_R_LS32>((?<IPV6_2_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_2_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_2_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_2_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ h16 ] "::" 4{ h16 ":" } ls32 )(?<IPV6_3_L_H16>[0-9a-f]{4,4})?\:\:((?<IPV6_3_R_H16>[0-9a-f]{4,4})\:){4,4}(?<IPV6_3_R_LS32>((?<IPV6_3_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_3_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_3_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_3_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ *1{ h16 ":" } h16 ] "::" 3{ h16 ":" } ls32 )(((?<IPV6_4_L_H16_REPEAT>[0-9a-f]{4,4})\:)?(?<IPV6_4_L_H16>[0-9a-f]{4,4}))?\:\:((?<IPV6_4_R_H16>[0-9a-f]{4,4})\:){3,3}(?<IPV6_4_R_LS32>((?<IPV6_4_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_4_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_4_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_4_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ *2{ h16 ":" } h16 ] "::" 2{ h16 ":" } ls32 )(((?<IPV6_5_L_H16_REPEAT>[0-9a-f]{4,4})\:){0,2}(?<IPV6_5_L_H16>[0-9a-f]{4,4}))?\:\:((?<IPV6_5_R_H16>[0-9a-f]{4,4})\:){2,2}(?<IPV6_5_R_LS32>((?<IPV6_5_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_5_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_5_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_5_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ *3{ h16 ":" } h16 ] "::" h16 ":" ls32 )(((?<IPV6_6_L_H16_REPEAT>[0-9a-f]{4,4})\:){0,3}(?<IPV6_6_L_H16>[0-9a-f]{4,4}))?\:\:(?<IPV6_6_R_H16>[0-9a-f]{4,4})\:(?<IPV6_6_R_LS32>((?<IPV6_6_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_6_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_6_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_6_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ *4{ h16 ":" } h16 ] "::" ls32 )(((?<IPV6_7_L_H16_REPEAT>[0-9a-f]{4,4})\:){0,4}(?<IPV6_7_L_H16>[0-9a-f]{4,4}))?\:\:(?<IPV6_7_R_LS32>((?<IPV6_7_R_LS32_IPV4_DEC_OCTET>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3,3}(?<IPV6_7_R_LS32_IPV4_DEC_OCTET_>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?<IPV6_7_R_LS32_H16_1>[0-9a-f]{4,4})\:(?<IPV6_7_R_LS32_H16_2>[0-9a-f]{4,4}))|(?# [ *5{ h16 ":" } h16 ] "::" h16 )(((?<IPV6_8_L_H16_REPEAT>[0-9a-f]{4,4})\:){0,5}(?<IPV6_8_L_H16>[0-9a-f]{4,4}))?\:\:(?<IPV6_8_R_H16>[0-9a-f]{4,4})|(?# [ *6{ h16 ":" } h16 ] "::" )(((?<IPV6_9_L_H16_REPEAT>[0-9a-f]{4,4})\:){0,6}(?<IPV6_9_L_H16>[0-9a-f]{4,4}))?\:\:(?# End ))$
/
g

Description

no description available

Submitted by anonymous - 7 years ago