You're going to have to use javascript regex to acheive this...
- Code: Select all
function doHighlight(bodyText, searchTerm)
{
bodyText = bodyText.replace(new RegExp("/[^\<^a-b^\>][\s a-z \.\,]*(" + searchTerm + ")[\s a-z \.\,]*/", "ig"), "<a href=\"http://www.domain.com/search.php?s=$1\">$1</a>");
return bodyText;
}
That's a pretty rough regex... not sure if it will work, I'm not far from bed it's 1 am :S..
This will be the only way you will get the replacing to happen without runing hardcoded links