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.