http://qs321.pair.com?node_id=1218243


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

If you specifically want to catch IP-addresses in brackets, I would first look for bracketed strings that contain digits, e.g. /(\(.*?0-9.*?\))/g, specifying "non-greedy" so that you get the shortest possible string.and applying this pattern as often as necessary to each input line. For each captured string, apply a Regexp::Common pattern to search for IP-addresses, also applying the pattern multiple times per-string. The check for digits occurring within the brackets is to reduce the number of false-positives on the first match loop.
  • Comment on Re: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

Replies are listed 'Best First'.
Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
by Anonymous Monk on Jul 10, 2018 at 15:13 UTC
    If a group could contain an inner parenthesized group then you may wish to use greedy patterns instead.
      If this is an issue, I would prefer to use Regexp::Common::Balanced.
      Bill
Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
by Anonymous Monk on Jul 11, 2018 at 14:03 UTC

    This "sundial" guy has been here for how many years? and he still doesn't know that <tt>...</tt> is not the way to mark off code. Dumbshit.

    A reply falls below the community's threshold of quality. You may see it by logging in.