title: Regex to match url path - Golang with Gorilla Mux
body: <p>I'm setting up an api endpoint which after parsing the url I would get a path such as <code>/profile/&lt;username&gt;</code> e.g. <code>/profile/markzuck</code></p>
  
  <p>The username is optional though as this endpoint returns the the authenticated users profile if username is blank</p>
  
  <p>Rule set:<br>
  I'm not the best at regex but I've created an expression that requires <code>/profile</code> after that if there is a following <code>/</code> e.g. <code>/profile/</code> then you need to have a <code>&lt;username&gt;</code> that matches <code>(\w){1,15}</code>. Also I want it to be allowed to match any number of combinations if there is another following <code>/</code> e.g. <code>/profile/&lt;username&gt;/&lt;if preceding "/" then anything else&gt;</code></p>
  
  <p>Although I'm not 100% sure my expression is correct this seems to work in JavaScript<br>
  <code>/^\/(profile)(\/(?=(\w){1,15}))?/</code></p>
  
  <p>Gorilla Mux though is different and it requires the route matching string to always start with a  slash and some other things I don't understand like it can only use non-capturing groups<br>
  ( found this out by getting this error: panic: route /{_dummy:profile/([a-zA-Z_])?} contains capture groups in its regexp. Only non-capturing groups are accepted: e.g. (?:pattern) instead of (pattern) )</p>
  
  <p>I tried using the same expression I used for JavaScript which didn't work here. I created a more forgiving expresion <code>handlerFunc("/{_dummy:profile\/[a-zA-Z_].*}")</code> which does work however this doesn't really follow the same rule set I'm using in my JavaScript expresion.</p>
  
  <p>I was able to come up with my working expresion from this SO post <a href="https://stackoverflow.com/questions/28950606/gorilla-mux-regex">here</a><br>
  And Gorilla Mux's docs talks a little bit about how their regex works when explaining how to use the package in the intro section <a href="https://godoc.org/github.com/gorilla/mux" rel="nofollow noreferrer">here</a></p>
  
  <p>My question is what is a similar or equivalent expression to the rule set I described that will work in Gorilla Mux <code>HandlerFunc()</code>?   </p>