xxxxxxxxxx
function replaceTextWithSpan(originalText, textToReplace) {
// Use a regular expression to replace the specified text with <span>specified text</span>
var modifiedText = originalText.replace(new RegExp(textToReplace, 'g'), '<span>' + textToReplace + '</span>');
return modifiedText;
}
// Example usage:
var originalString = "A Hoàng LDP, C. Test, Xuân Như dự:";
var textToReplace = "C. Test";
var modifiedString = replaceTextWithSpan(originalString, textToReplace);
console.log(modifiedString);