in reply to Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

Somewhat crude, but passes your test cases without false positives:
use strict; use warnings; use feature "say"; while (<DATA>){ my @ips = m/\(([\d\.:]+)[\s<>]*([\d\.:]+)?[\s<>]*([\d\.:]+)?\)/; $_ and say "$. >$_<" for @ips; } __DATA__ email (209.85.208.68) (172.217.194.27 < 209.85.208.68) (172.217.194.27 < 2001:4860:4860:0:0:0:0:8888) (2001:4860:4860:0:0:0:0:8888) (2001:4860:4860:0:0:0:0:8888 < 2001:4860:4860::8844) (2001:4860:4860:0:0:0:0:8888 < 172.217.194.27) (2001:4860:4860:0:0:0:0:9999 < 172.217.194.29 Not terminated by close +paren Sometimes, it appears in this way too. It may have IPV6 as well. (172.217.194.27 < 172.217.194.27 < 209.85.208.68) Anyway, I stared with below. It won't fulfill. It can catch ipv
Output:
2 >209.85.208.68< 3 >172.217.194.27< 3 >209.85.208.68< 4 >172.217.194.27< 4 >2001:4860:4860:0:0:0:0:8888< 5 >2001:4860:4860:0:0:0:0:8888< 6 >2001:4860:4860:0:0:0:0:8888< 6 >2001:4860:4860::8844< 7 >2001:4860:4860:0:0:0:0:8888< 7 >172.217.194.27< 10 >172.217.194.27< 10 >172.217.194.27< 10 >209.85.208.68<

                Memory fault   --   brain fried

Replies are listed 'Best First'.
Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
by theravadamonk (Scribe) on Jul 10, 2018 at 05:39 UTC

    Thanks for your reply.

    IPV6 have characters as well. see below stuffs

    2404:6800:4003:c04::5e

    2600:3c00::f03c:91ff:fedf:f016

    So, In YOUR below code, \d can be replaced with \w

     my @ips = m/\(([\w\.:]+)[\s<>]*([\w\.:]+)?[\s<>]*([\w\.:]+)?\)/;

    \w Matches any letter, digit or underscore. Equivalent to a-zA-Z0-9_

    it's greedy isn't it ? anyway, Thanks for your effort.