title: Regular expression to validate string format to specific length with csv
body: <p>I am trying to write a regular expression which validates a text box to have only digits with length 5 or 9. I found the below regular expression to get this done</p>
  
  <pre><code>^\d{1,5}([,]\d{5})*$
  </code></pre>
  
  <p>but it could not fix my requirement correctly, Can any one please help me in modifying or writing a new regular expression which supports below pattern. </p>
  
  <ul>
  <li>09103,09101,     <strong>valid</strong>    <em>(ending with comma)</em></li>
  <li>09103,09101      <strong>valid</strong>    <em>(not ending with comma)</em></li>
  <li>12345,1234567    <strong>Invalid</strong>  <em>(should not support if 1st digit is length 5 and 2nd less than 9)</em></li>
  <li>12345,123456789  <strong>valid</strong>     <em>(must support only digit length 5 or 9)</em></li>
  </ul>