View Single Post
  #2 (permalink)  
Old Jan 4th, 2008, 12:42
Rakuli's Avatar
Rakuli Rakuli is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Detecting characters between < and > ?

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
Reply With Quote