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

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.

  • Comment on Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
  • Download Code