I have a regular expression for IPv6 addresses as given below
IPV4ADDRESS [ \t]*(([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3}))[ \t]*
x4 ([[:xdigit:]]{1,4})
xseq ({x4}(:{x4}){0,7})
xpart ({xseq}|({xseq}::({xseq}?))|::{xseq})
IPV6ADDRESS [ \t]*({xpart}(":"{IPV4ADDRESS})?)[ \t]*
It is correctly all formats of IPv6 addresses including
1) non-compressed IPv6 addresses
2) compressed IPv6 addresses
3) IPv6 addresses in legacy formats.(supporting IPv4)
Ideal examples of IPv6 addresses in legacy formats would be
2001:1234::3210:5.6.7.8
OR
2001:1234:1234:5432:4578:5678:5.6.7.8
As you can see above there are 10 groups separated by either `":" or ".".`
As opposed to 8 groups in normal IPv6 addresses.This is because the last 4 groups that are separated by `"." should be compressed into least significant 32-bits of the IPv6 addresses.Hence we need 10 groups to satisfy 128 bits.
However If I use the following address format
2001:1234:4563:3210:5.6.7.8
Here each group separated by ":" represents 16-bits.the last four groups separted by "." represents 8 bits.Total number of bits is 64 + 32 = 96 bits.32 bits are missing
The regular expression is accepting it as a valid IPv6 address format.I am unable to figure out how to fix the regular expression to discard such values.Any help is highly appreciated.