title: php - regex to return ip addresses from lines of text
body: <p>I'm trying to use a regex to capture ip addresses in lines of text. Right now it's kind of screwed up. My code returns ip addresses when lines of text don't contain ip addresses and sometimes it returns "Script)". What am I doing wrong? I would like to return the ip addresses of lines that actually have them, and return nothing if they don't.</p>
  
  <p>Text</p>
  
  <pre><code>2014-06-02 11:53:54.410 -0700   Information 638 NICOLE  Client "123456" opening a connection from "123456.local (207.230.229.204)" using "Go 13.0.4 [fmapp]".
  2014-06-02 11:54:52.504 -0700   Information 98  NICOLE  Client "123456 (123456.local) [207.230.229.204]" closing database "FMServer_Sample" as "Admin".
  2014-06-02 12:07:33.433 -0700   Information 638 NICOLE  Client "[WebDirect]" opening a connection from "207.230.229.204 (207.230.229.204)" using "Win Chrome 35.0 [fmwebdirect]".
  2014-06-02 13:05:00.088 -0700   Information 638 NICOLE  Client "Showare Update" opening a connection from "FileMaker Script" using "Server 13.0v1 [fmapp]".
  2014-06-02 13:05:22.366 -0700   Information 98  NICOLE  Client "Showare Update (FileMaker Script)" closing database "cac" as "opus".
  2014-06-02 12:08:04.165 -0700   Information 98  NICOLE  Client "[WebDirect] (207.230.229.204) [207.230.229.204]" closing database "FMServer_Sample" as "Admin".
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>if(preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $line, $ip_matches)) {
      $client_ips = $ip_matches[1];
  }
  
  print "&lt;pre&gt;;
  print_r($client_ips);
  print "&lt;/pre&gt;";
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>207.230.229.204
  207.230.229.204
  207.230.229.204
  207.230.229.204
  207.230.229.204
  Script)
  </code></pre>