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.