Hi All,
Anybody can please me for regexmatch code IPv6 Ip Address. I an using this regex code
"^([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}$"
Using above code this scenario:
a) :2551:FFFF::3333:4566:3456:0 is also vaild but I don't want to start IP address with any special character.
Some of the example below that I want to match regex code valid and invaild like:
a) :2551:FFFF::3333:4566:3456:0 (Invalid)
b) 1001:2551:FFFF:255b:1222:3333:4566:3456 (valid) 1001:2551:F:255b:1222:3333:4566:3456 (valid)
c) 1001:::255b::::3456 (vaild)
d) 1001:::255b:::456: (invalid)
I need a regex match code which passed all the above mention examples.
Thanks
Discussion posts and replies are publicly visible
This will be tricky if you're expecing it to accept all possible combinations including the shortform notation where zero-segments can be skipped with the "::" notation. I assume it's possible but your match pattern will probably end up quite a bit more complicated.
A quick google result (leading to StackOverflow) suggests this pattern might work (i'm not 100% sure how Appian-compatible this will be, but it seems to work for me at a first glance)
(?:^|(?<=\s))(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(?=\s|$)
Edit: i tried it out and it seems to work as-desired for all your examples except "c", though i think your example "c" might actually not be valid without editing (i think maybe only one "::" shortcut is valid in the sequence? not sure.)
Thanks Mike Schmitt for the response
But as you mention that 1001::255b:3456 this is vaild IP Address .
According to my scenerio the above IP address is Invaild .
jojog0003 said:According to my scenerio the above IP address is Invaild
Can you clarify whether you intend to accept the shortform notation of "::" implying that all in-between segments are just "0"? This is what the standard I looked up said - and this suggests that the quoted example is valid (i don't know much more about it than that).
Here's the standard I was referencing earlier: https://www.ibm.com/docs/en/ts4500-tape-library?topic=functionality-ipv4-ipv6-address-formats
relevant similar example is the one highlighted: