title: Regex: Repeat pattern n times, with variation on final repetition
body: <p>I have a regular expression which is intended to match a specific syntax, <em>n</em> times, with a pipe (|) following each occurrence, except for the final occurrence. Currently, my pattern is along the lines of <code>(pattern)\|{3}</code>, but this doesn't satisfy the requirement that there is no trailing pipe. Is there anyway I can accomplish this <em>without repeating</em> <code>(pattern)</code>? The best solution I can think of is <code>(pattern)\|{2}(pattern)</code>.</p>
  
  <p><strong>Valid Example:</strong></p>
  
  <blockquote>
    <p>*|401|[2-10]</p>
  </blockquote>
  
  <p><strong>Invalid Example:</strong></p>
  
  <blockquote>
    <p>*|401|[2-10]|</p>
  </blockquote>
  
  <p>The value of <code>(pattern)</code> is extraneous to answering my specific question, but for completeness, here it is in its current form: <code>(?:(?:((\*)|(\[[\w+ ]\-[\w+ ]\])|(\d+)))\|){3}</code></p>
  
  <p><em>Edit</em></p>
  
  <p>This is being consumed within .NET and JavaScript.</p>