I've been working on a regular expression that searches for all capital letters within a document and successfully stores them in an array. However, I'm struggling to wrap each item in the array with a span tag before displaying the updated result.
Despite numerous attempts, I haven't been able to figure it out. Any assistance would be greatly appreciated. Below is my most recent attempt:
var allCaps = new RegExp(/(?:[A-Z]{2,30})/g);
var capsArray = [];
var capsFound;
while (capsFound = allCaps.exec(searchInput)) {
capsArray.push(capsFound[0]);
}
//for(var x = 0; x < capsArray.length; x++){
//var test = ;
capsArray.splice(0, '<span style="color:green">'+ capsArray +'</span>');
//}
}