title: Using ereg_replace or preg_replace to leave part of a filename in php
body: <p>I am trying to leave only the prefix (WST in the example below) and the number.  Any suffix and file extension should be removed.  This should leave me with the product code in tact.</p>
  
  <p>Here are three possible values:</p>
  
  <pre><code>39159 FLAN.jpg
  22201-HAV.jpg
  WST 503.jpg
  </code></pre>
  
  <p>The output I need for these three examples is:</p>
  
  <pre><code>39159
  22201
  WST 503
  </code></pre>
  
  <p>Here is my current <code>ereg_replace</code>, but it also removes the prefix before the number:</p>
  
  <pre><code>$number  = ereg_replace("[^0-9]", "", $value);
  </code></pre>