I have a text file that contains IP address ranges defined as follows:
10.30.8.4
10.30.6.[10:12]
10.30.[8:9].4
[10:11].30.12.23
[10:11].[28:29].[11:12].[22:23]
by parsing this with a regex, I'm expecting the output to be
10.30.8.4
10.30.6.10
10.30.6.11
10.30.6.12
10.30.8.4
10.30.9.4
10.30.12.23
11.30.12.23
10.28.11.22
10.28.11.23
10.28.12.22
10.28.12.23
10.29.11.22
10.29.11.23
10.29.12.22
10.29.12.23
11.28.11.22
11.28.11.23
11.28.12.22
11.28.12.23
11.29.11.22
11.29.11.23
11.29.12.22
11.29.12.23
this is what I got so far
$ips = Get-Content C:\temp\hosts.txt
$regex = [regex] "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
$regex.Matches($ips) | %{ $_.value }
This only gets the first IP address but not the others