Requires regex. I recently did something but I'm particularly interested in sharing my code. What project are you working on?
–
Jackson GarietyMay 4 '12 at 23:45

Where is the text coming from? From a server? And why is it in that format?
–
Šime VidasMay 4 '12 at 23:51

@JacksonGariety Requires is a strong word :) This is quite a simple case that could be parsed and replaced manually. For a regex beginner, that could be even easier. Although, op wouldn't be asking then :)
–
ImpMay 4 '12 at 23:52

What needs to be done is grab all the text nodes on the page and use regex to filter out the parts that contain hashtags. Then use a .replace() javascript to add in the anchor tags around.
–
Jackson GarietyMay 4 '12 at 23:54

2 Answers
2

Below is the code you can use to replace hash signs with a link. Feel free to experiment with it, and comment any questions you may have :)

var text = "Hello, I'm a #robot and this is my #home.";
alert(text.replace(/#([a-z0-9]+)/gi, '<a href="blah.com/$1">#$1</a>'));
// It alerts the following "Hello, I'm a <a href="blah.com/robot">#robot</a> and this is my <a href="blah.com/home">#home</a>."

jQuery is not intended for pure text manipulation. I guess the best alternative here would be do such changes server-side. If not possible, a simple find/replace would do the trick, in such case jQuery could be used just to iterate over some elements that contains this HTML, making its access easier.