views:

452

answers:

2

I don't know enough to change the following so that it only puts <strong> around the first found string matching the term:

highlight: function(value, term) {
    return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\]){1}/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
}

This is from the jQuery autocomplete plugin: http://docs.jquery.com/Plugins/Autocomplete or http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

By default if you type "a" in the field, the the following results would look like "Apple Ate Ants" and I only want "Apple Ate Ants".

+2  A: 

Try changing the last "gi" to "i" (the "g" tells it to replace all matches).

Dave Cluderay
Thxs, I knew it was simple, just not up on my regex.
Darryl Hein
A: 

this solutions is not working please provide me another solution

vikram
How is it not working?
Darryl Hein