Regex to match JSON Web Token within URL
<p>I need a little help refining this regex to be able to identify a JWT token within an URL string using PHP. This matches a token fine but not if I append another URI segment.</p>

<p>Regex so far:</p>

<pre><code>/[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)$/
</code></pre>

<p>URL this works for:</p>

<pre><code>http://not.website.com/**eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ**
</code></pre>

<p>URL it doesn't work for (note additional segments on the end)</p>

<pre><code>http://not.website.com/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ/additional/segments
</code></pre>

<p>The expected match should look like:</p>

<pre><code>http://not.website.com/**eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ**/additional/segments
</code></pre>