Is it possible to check a string with a single regex and validate it if matches valid IPv4 or IPv6 address or even a hostname with no special characters but dot (.)?
I have separate regex for IPv4 and IPv6 but how do I combine them to do the work described above?
Thanks in advance,
Dan
You could use a single regex, but it’s going to be ugly as hell. Either;
Perl-ish example:
Having said that, there are probably libraries in Python that will validate these things for you, and personally I’d rather rely on them.