title: JavaScript Hash Tag Parsing Function
body: <p>I already had two regex functions to parse url's and replies from a json twitter response but I tried to extend it to parse hash tags aswell but I am getting <code>undefined</code> displayed in palce of the hashtag:</p>
  
  <pre><code>// process links, reply and hash tags
  tweet = tweet.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/ig, function(url) {
          return '&lt;a href="'+url+'"&gt;'+url+'&lt;/a&gt;';
      }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
          return  reply.charAt(0)+'&lt;a href="http://twitter.com/'+reply.substring(1)+'"&gt;'+reply.substring(1)+'&lt;/a&gt;';
      }).replace(/#([a-zA-Z0-9]+)/g), function(hash) {
          return '&lt;a class="hashtag" target="_blank" href="http://twitter.com/#search?q='+$1+'"&gt;#'+$1+'&lt;/a&gt;';
      };
  </code></pre>
  
  <p>Any pointers on where I'm going wrong?</p>