I use a replace to wrap all the words in a string with <a/> tags, but if a word contains a dash or hyphen it splits the word, e.g: hello-there becomes hello - <a>there</a>.
This is what I use now:
string.replace(/\b(\w+)\b/g, '<a href="javascript:void(0)">$1</a>');
Also, how can I remove periods or commas from the words?
1 Answer