I searched through the online resources i found for this particular quest, but im stuck with something that i couldn't get help through them. I'm trying to find a way to add style to the first matched letter in an array and discard the remaining matched letters.eg say I have a search string called: "disabledDouble". I use the split() method on the string to separate the matched element from the unmatched ones:
search: function(){
var search = "d";
var string = "disabledDouble";
var regex = new RegExp("(" + search + ")", "gi");
var segments = string.split(regex); //o/p :["d", "isable", "d","D","ouble"]
return (
//styled element <span>
)
}
now i want to just add style to the first 'd' in the array (not worry about the second or third 'd's') and join the remaining string such that o/p becomes:
disabledDouble
similarly since the string is dynamically created I've values like:
showStability
accessValues
In all the above cases I'd like to add style only to the first matched value. any ideas???