I have a string, I want to replace the specific word and also want to count the number of occurrence. e.g
"Of course, there are many other open source or commercial tools available.
Twitter typeahead is probably the most important open source alternative."
.replace(/source/g,'<b>source</b>');
This will replace all source
with <b>source</b>
but I want the count of occurance of source
also i.e 2
.