When using Python 3 with Regex I am getting unexpected results. I want to do something like this
firstpass = re.findall('\s+((10|192|172).\d{1,3}.\d{1,3}.\d{1,3}/(\d+))', line)
Where it would look for spaces, then numbers starting with 10 or 192 or 172 and then any 3 octets after (IPv4 addresses).
I understand the grouping but I either get only one of the first three values. Or if I change the grouping around I get get 3 returns (but still only 1 of the initial search values) I've tried as many variations as I can read about. the [10|192|172] just doesn't work. inside () groupings of course.
I am looking for two return strings. The IP and the mask. It works fine until I try to enlarge my expression to have a more complex search.
the end goal is to look for ANY private IP space in one regex expression.
10.match.match.match
172.16-32.match.match
192.168.match.match
So the data may look like this and I want to pull 1 -3 but not the last line
B 10.50.13.0 /26 blah foo
O 192.169.5.0 /24 foo foo
B 172.18.0.0/16 etc etc
B 82.33.4.0/24 yak yak yak