Let’s say I have some HTML:
Hello, I'm a #robot and this is my #home.
How can I turn this into:
Hello, I'm a <a href="blah.com/robot" class="tag">#robot</a> and this is my <a href="blah.com/home" class="tag">#home</a>
I’ve tried using JQuery by iterating over each word and doing a find/replace, but it was very expensive. What’s a better way to do it?
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 🙂