Get protocol, hostname, and path from URL
<p>I have made a Regular expression that captures the Short URL of a link. For example:</p>

<pre><code>https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=picture%20of%20a%20potato
</code></pre>

<p>My regular expression would be:</p>

<pre><code>/(https:\/\/.+?)\/.+/
</code></pre>

<p>Now this would only capture: </p>

<pre><code>https://www.google.com
</code></pre>

<p>What I want to do now is store the captured RegEx into a variable. Any help or suggestions are greatly appreciated.</p>