title: preg_match_all on process ids in string
body: <p>I'm trying to get certain ids from a string, but I can't get it to work. I'm getting values that I'm not expecting in my result.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>&lt;?php
  $grep = ' 7027 ?        S      0:00 nginx: worker process                                          
   7632 ?        S      0:00 sh -c ps ax | grep nginx
   7634 ?        S      0:00 grep nginx
  16117 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf';
  
  
  if ( preg_match_all('~([0-9]+) \?(.*?)nginx:~si', $grep, $matches) )
  {   
      echo '&lt;pre&gt;';
      print_r($matches);
      echo '&lt;/pre&gt;';
  }
  </code></pre>
  
  <p>What I'm expecting here with: <code>~([0-9]+) \?(.*?)nginx:</code> is that it would match these two lines:</p>
  
  <pre><code>7027 ?        S      0:00 nginx: worker process  
  16117 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf';
  </code></pre>
  
  <p>I'm specifically after their process id, in this case: <code>7027</code> and <code>16117</code>.</p>
  
  <p>But I'm getting: <code>7027</code> and <code>7632</code> instead.</p>
  
  <p>How should my regex look to get the data that I want?</p>
  
  <p>Here's a demo: <a href="http://codepad.viper-7.com/2R5OfF" rel="nofollow">http://codepad.viper-7.com/2R5OfF</a></p>