Parse text to format URLs from content and shorten URLs
<p>I would like to parse the following text into formatted URLs with anchor tags:</p>

<pre><code>something is wrong with http://www.gbin1.com/index.html,  but cannot find the reason in http://www.google.com
</code></pre>

<p>How can I replace the text URLs above with <code>&lt;a href="url"&gt;url&lt;/a&gt;</code> and also shorten it using JavaScript as displayed below:</p>

<pre><code>something is wrong with &lt;a href="http://www.gbin1.com/index.html"&gt;gbin1.com&lt;/a&gt;,  but cannot find the reason in &lt;a href="http://www.gbin1.com"&gt;google.com&lt;/a&gt;
</code></pre>
