UPDATE 1:
Really sorry about this, I just realised I made a mistake with the question.
If data = some @text1 here, and @text2 here
It should become
some <a href="http://www.google.com/?q=text1">@text1</a> here, and <a href="http://www.google.com/?q=text2">@text2</a> here
ORIGINAL QUESTION:
Using jQuery AJAX, I am returning data and outputting it like this:
$('.class_name_here').append( data )
Within data I want to be able to search for certain characters, then add urls to them before outputting them, e.g.
lets say data contains
some @test here
I want to find the word which follows after @ and add http://www.google.com to it, so I end up with
some <a href="http://www.google.com">@test</a> here
Should work, a simple regex replace. And a nice demo can be found here.
Update:
Try this on for size:
That will wrap all
@keywordsin a<a href="http://google.com/?q=keywords">@keywords</a>, for instance.Demo of this, too