Java Regex applicable for two strings
<p>I need help with a Java Regex. I have a filename string which can have either of the below formats: </p>

<blockquote>
  <p>number-yyyymmdd.text_1.xml</p>
</blockquote>

<p>OR</p>

<blockquote>
  <p>yyyymmdd.text_1.xml</p>
</blockquote>

<p>I am able to get the &lt;number> and &lt;yyyymmdd> from the first format using below regex:</p>

<p><code>"\\-(.*?)\\."</code> - gives me yyyymmdd</p>

<p><code>"(.*?)\\-";</code> - gives me number</p>

<p>But with 2nd format (i.e. with &lt;yyyymmdd>.text_1.xml) it throws error and doesn't return &lt;yyyymmdd>. I need one regex for date format that will work with both strings.</p>

<p>Could you please help?</p>