PHP: Need to extract certain part of string using preg_match()
<p>I'm try to extract the "INV" part of the string below:</p>

<pre><code>123_456_P1234_INV_UID-123456.PDF
</code></pre>

<p>Here's the code I have so far:</p>

<pre><code>php -r 'echo preg_match("/_(.*?)_UID-.*?\.PDF$/", "123_456_P1234_INV_UID-123456.PDF", $cat) ? $cat[1]."\n" : "";'
</code></pre>

<p>This returns:</p>

<pre><code>_456_P1234_INV
</code></pre>

<p>Can anyone tell me why it's including everything before the INV bit? How can I fetch just the INV part please?</p>
