Currently I am using this script (http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html) on my website - www.tompainetoday.com.

It works when you hover your mouse over a "Trending Now:" term, then that word is highlighted throughout the page. The highlighting is removed when you hover over the header image (yes, I know, poor UX, but it works).

The problem arrises when the trending word is short, and ends up being highlighted inside of other, larger words, since this script makes no distinction between words and a list of characters.

Basically, I think this can be done rather easily by only highlighting the characters if the character prior and after the word are not a letter.

I tweeted the developer of this script and suggested it be edited with:
new RegExp("\W" + pat + "\W").test
I have no experience with regex, and only minimal with JavaScript.

Any help in fixing this out would be much apprecaited!

Thanks!

The above line: "I tweeted the developer of this script and suggested it be edited with:"
Should read: "I tweeted the developer of this script and he suggested it be edited with:"

Not 100% sure but I think it should be:

new RegExp("\\b" + pat + "\\b").test

Pritaeas, where would I use this line of code?

I don't know. I thought the developer told you where to change it. If you can't get it to work, I have something similar here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.