How do I extract data from this URL using javascript?
<p>I need to build a string from the data contained in this url using javascript/jQuery:</p>

<pre><code>http://www.example.com/members/admin/projects/?projectid=41
</code></pre>

<p>The string returned should look as follows:</p>

<pre><code>/ajax/projects.php?projectid=41
</code></pre>

<p>Obviously if there is no query string present, the method should still return a string of the same format minus the query string. e.g.</p>

<pre><code>http://www.example.com/members/admin/messages/
</code></pre>

<p>should return...</p>

<pre><code>/ajax/messages.php
</code></pre>

<p>I've made numerous attempts, all met without success due to my poor grasp of regular expressions, and it feels as though the ore I rad on the subject the more I am confusing myself.</p>

<p>If someone could help it would be greatly appreciated.</p>

<p>EDIT: The 'admin' portion of the url is a users 'username' and could be anything.</p>
