javascript - Using regular expressions to find and replace within a string with additional style -
i have raw text need output, have search box highlight parts of text match entered in search box.
this works, find search box contents:
replace="<span class='highlight'>"+find+"</span>"; var results = drawstring.replace(new regexp(find, 'gi'), replace); return results;
my problem want match regardless of case i'll replacing exact input of user. want retain case of original value before replace, how can done.
you can use matched string inside replace value:
replace="<span class='highlight'>$&</span>";
Comments
Post a Comment