Javascript - Make specific text a link : <p>I'm looking at a 'to do' list application that uses JavaScript.
One of the functions converts text in to a hyperlink when https, https or ftp is present.</p>

<p>I'd like to expand this so if my text contains # followed by any 5 digit number, that becomes a link as well. The URL should be  <code>http://192.168.0.1/localsite/testschool/search.php?id=ID</code></p>

<p>where ID is the # and 5 digit number.</p>

<p>This is the current Javascript:</p>

<pre><code>function prepareHtml(s)
{
    // make URLs clickable
    s = s.replace(/(^|\s|&gt;)(www\.([\w\#$%&amp;~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|&amp;quot;|&amp;lt;|&amp;gt;|\"|&lt;|&gt;|$)/gi, '$1&lt;a href="http://$2" target="_blank"&gt;$2&lt;/a&gt;$4');
    return s.replace(/(^|\s|&gt;)((?:http|https|ftp):\/\/([\w\#$%&amp;~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|&amp;quot;|&amp;lt;|&amp;gt;|\"|&lt;|&gt;|$)/ig, '$1&lt;a href="$2" target="_blank"&gt;$2&lt;/a&gt;$4');
};
</code></pre>

<p>called using <code>prepareHtml(item.title)</code></p>

<p>Any idea how I can do this ?
I've worked out regex to match the # and 5 digits is <code>^#([0-9]{5})</code> but I'm not sure how to implement this in the function.</p>

<p>Thanks</p>
