title: PHP preg_match between text and the first occurrence of -
body: <p>I'm trying to grab the 12345 out of the following URL using preg_match.</p>
  
  <pre><code>$url = "http://www.somesite.com/directory/12345-this-is-the-rest-of-the-url.html";
  
  $beg = "http://www.somesite.com/directory/";
  $close = "\-";
  preg_match("($beg(.*)$close)", $url, $matches);
  </code></pre>
  
  <p>I have tried multiple combinations of . * ? \b</p>
  
  <p>Does anyone know how to extract 12345 out of the URL with preg_match?</p>