Given a needle and a haystack... I want to put bold tags around the needle. So what regex expression would I use with replace()? I want SPACE to be the delimeter and I want
For those who don't want SPACE as the delimiter, simply don't use \s.
\s
function updateHaystack(input, needle) { return input.replace(new RegExp('(^|)(' + needle + ')(|$)','ig'), '$1$2$3'); }
Worked for me.