I'm trying to retrieve the IP address from a string. I'm definitely not the first to ask this question, but I couldn't really find an answer doing exactly what we need.
If there is somewhere in the string a combination of xxx.xxx.xxx.xxx, regardless of the text around it, it should extract this number with the dots in between. So it can be used with Test-Connection
.
I'm not trying to determin if an IP Address is valid, but I am trying to retrieve the IP Address from a string. Even if it is invalid, like say 900.999.800.254.
Example:
Input Expected result
----- ---------------
IP_10.57.50.91 10.57.50.91
10.57.50.73 10.57.50.73
10.58.4.37 IP 10.58.4.37
ip 10.63.1.22 10.63.1.22
BELPRLIXH300 $False
ip 10.63 $False
I've tried so far the the regex's suggested here but they don't give us the IP address as output in the variable $Matches
.