title: Regular expression, specific last character type in a capture group
body: <p>The regex I currently have is:</p>
  
  <pre><code>"^(?:(\\.\\.)|^([a-z]+[a-z.\\-]*)([\\*]?)[\\[]*([^\\]]*)[\\]]*)$";
  </code></pre>
  
  <p>It captures either ".." (group 1) with group 2-4 being empty<br>
  <strong>or</strong>:<br>
   - a group of lowercase, dots, dashes. starting with lowercase (group 2)<br>
   - followed by optional asterisk (group 3)<br>
   - followed by optional content within square brackets (group 4)</p>
  
  <p>I'm having a couple problems, first is making it so group2 must end with a letter, I have tried many things including: </p>
  
  <pre><code>"^([a-z]+[a-z.\\-]*[a-z]$)"
  "^([a-z]+[a-z.\\-]*[a-z])$"
  </code></pre>
  
  <p>which kills anything in group 3-4</p>
  
  <pre><code>"^([a-z]+[a-z.\\-]*[a-z])"
  </code></pre>
  
  <p>which doesn't seem to do anything different</p>
  
  <hr>
  
  <p>The other problem I'm having is group 4, it doesn't depend on the square brackets (which makes sense as I have the * character for them)... but if I remove that character it will not give me any results for ANY of the groups.</p>
  
  <p>Any help is greatly needed and appreciated.</p>
  
  <hr>
  
  <p>In response to comment below, the following should match:<BR><code>"string" - (group1)(group2)(group3)(group4)</code></p>
  
  <pre><code>".." - (..)()()()
  "blah" - ()(blah)()()
  "blah.blah" - ()(blah.blah)()()
  "blah.blah*" - ()(blah.blah)(*)()
  "blah*" - ()(blah)(*)()
  "blah.blah*[foobar] - ()(blah.blah)(*)(foobar)
  "blah[foobar] - ()(blah)()(foobar)
  </code></pre>
  
  <p>The following should not match:</p>
  
  <pre><code> "."
   "..."
   ".blah"
   "blah."
   ".blah*"
   "blah.*[foobar]
  </code></pre>