Related (but slightly different):
http://stackoverflow.com/questions/1181204/javascript-regex-surround-and-http-with-anchor-tags-in
I would like to surround all instances of @___, #____, and http://________
with anchor tags. Multiple passes is fine with me.
For example, consider this Twitter message:
The quick brown fox @Spreadthemovie jumps over the lazy dog #cow, http://bit.ly/bC9Dy
Running it with the desired regex pattern would yield:
The quick brown fox <a href="blah/Spreadthemovie">@Spreadthemovie</a> jumps over the lazy
dog <a href="blah/cow">#cow</a>, <a href="blah/http://bit.ly/bC9Dy">http://bit.ly/bC9Dy</a>
Only surround words that start with @, # or http:// so that [email protected] would not become [email protected]. Also, note how "#cow,
" turned into "<a href=urlB>#cow</a>,
" ... I only want alpha-numeric characters to be on the end of each anchor tagged substring. Also notice the href attribute.
If possible, please include actual javascript code with the regex pattern and replace function.
Many thanks! This problem has been plaguing me for a while