Match 1, 2, or 3 digit number between two slashes
<p>I'm reading a URL string that holds year and pagination page. They come in two variations:</p>

<p><code>/news/2016/2</code> and <code>/news/2/2016</code></p>

<p>The smaller number is the pagination number and it should never be bigger than 3 digits. The 4 digit number is the year.</p>

<p>I'm able to match the year: <code>/\d{4}/</code> and the pagination 3 digit limit, however I can't make it force the starting forward slash. I tried these two solutions:</p>

<p><code>[1-9]?\d(?=\/|$)</code> - it will match 1 through 3 digit number, but it ignores the starting slash, so the year will match as well.</p>

<p><code>(?=\/)[1-9]?\d(?=\/|$)</code> - the way the documentation explains it, but it doesn't match anything...</p>

<p>P.S. This is for javascript.</p>