title: Overcomplicating regular expression
body: <p>I have the following regular expression <code>^(?:\/foo\/)([A-Za-z0-9-]{0,})|^(?:\/foo)</code> that needs to match <code>/foo</code>,<code>/foo/</code>, <code>/foo/abc-123</code> but not <code>/foobar</code>. This works, I've tested it but I'm sure there is a simpler way using something like lookbehind or ahead.</p>
  
  <p>How can I simplify it, or do I need to? Maybe it's just me being over paranoid about the ugliness of it. Maybe drop the non capturing groups, to have <code>^\/foo\/([A-Za-z0-9-]{0,})|^\/foo</code> still doesn't look right</p>
  
  <p><strong>Note</strong> the goal is to capture <code>abd-123</code> if present, but not capture the <code>/</code> or the empty string</p>