title: How to extract a complex version number using sed?
body: <p>I use sed in CentOs to extract version number and it's work fine:</p>
  
  <p><code>echo "var/opt/test/war/test-webapp-4.1.56.war" | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'</code></p>
  
  <p>But my problem is that i am not able to extract when the version is shown like this: </p>
  
  <p><em>var/opt/test/war/test-webapp-4.1.56-RC1.war</em> </p>
  
  <p>I want to extract the <strong>4.1.56-RC1</strong> if it is present.</p>
  
  <p>Any ideas ?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Ok to be clear take this example, with a path:</p>
  
  <p>Sometimes the path contains only a serial number like this var/opt/test/war/test-webapp-<strong>4.1.56</strong>.war and sometimes it contains a series of numbers and letters like this "var/opt/test/war/test-webapp-<strong>4.1.56-RC1</strong>.war</p>
  
  <p>The need is to recover either <strong>4.1.56</strong> or <strong>4.1.56-RC1</strong>  depending on the version present in the path. With sed or grep, no preference.</p>
  
  <p>This seems to work but the .war is shown at the end:</p>
  
  <pre><code>echo "var/opt/test/war/test-webapp-4.1.56.war" | egrep -o '[0-9]\S*'
  </code></pre>