title: Regex to extract an IP address from a string
body: <p>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.</p>
  
  <p>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 <code>Test-Connection</code>.</p>
  
  <p>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.</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p>I've tried so far the the regex's suggested <a href="https://chrisjwarwick.wordpress.com/2012/09/16/more-regular-expressions-regex-for-ip-v4-addresses/" rel="nofollow">here</a> but they don't give us the IP address as output in the variable <code>$Matches</code>.</p>