How would I modify this IPv6 regex I wrote to either detect the address (ie the way the regex is written right now), but also accept "blank" ie the user did not specify an IPv6 address?
^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$
Right now, the regex is looking for a minimum of 0:0:0:0:0:0:0:0 or similar. Infact in addition to a blank address, I probably need to also be able to handle compression such as the following address:
FE80::1
or ::1
etc
Thanks!
* UPDATE *
So let me make sure I have this straight...
(^$|^IPV4)\|(^$|IPV6)\|REST OF STUFF$
That doesn't seem right. I feel like I have misplaced the ^ and $ and the very beginning and end of my entire regex.
Maybe this instead:
^(^$|IPV4)\|(^$|IPV6)\|REST$
* UPDATE *
Still no luck. Here is part of my code with the middles chopped out for sanity:
^(|[0-9]{1,3}.<<<OMIT MIDDLE IPV4>>>.[0-9]{1,3})\|(|(\A([0-9a-f]{1,4}:){1,1}<<<OMIT MIDDLE IPV6>>>[0-1]?\d?\d)){3}\Z))\|[a-zA-Z0-<<<MORE STUFF MIDDLE OMITTED>>>{0,50}$
I hope that isn't confusing. Thats the beginning and end of each regex with the middles omitted so you can see the ( ).
Perhaps I need to enclose the entire gigantic IPV6 regex in parenthesis?
* UPDATE *
Tried last statement above... no luck.