Created
April 29, 2013 16:36
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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