Skip to content

Instantly share code, notes, and snippets.

@Usse
Created April 29, 2013 16:36
Show Gist options
  • Save Usse/5482829 to your computer and use it in GitHub Desktop.
Save Usse/5482829 to your computer and use it in GitHub Desktop.
Wrap with an <a> element all the '#tag' occurrences in a string. Usefull for twitter json.
function test_if_hashtag(string) {
var thestring=string;
var pattern = /#([a-zA-Z0-9]+)/g;
return thestring.replace(pattern, "<a href='https://twitter.com/search?q=%23$1' target='_blank'>#$1</a>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment