I'm trying to implement a search where I only match and bold the start of the word in Javascript.
So, if you search for "choc", "chocolate" would appear, but if you search for "late", Chocolate wouldn't appear.
I've got:
if( queryString.match(new RegExp('/\b'+inputField.val()+'/', 'gi')) )
And then to highlight the word:
var tempName = queryString.replace(new RegExp('(^|\b)(' + inputField.val() + ')(|$)','ig'), '$1<strong>$2</strong>$3');
But nothing is working the way I had hoped. Any ideas?