If you use the regular expression /(this|a)/
Now if I have:
var text = "this is a sentence.";
text = text.replace(/(this|a)/gi, "_");
document.write(text);
I get the output: _ is _ sentence
I am working on a piece of Javascript that does selective styling so what I want to do is add '<span class="className">" + word_in_regex + "</span>"
where word_in_regex
is the word from the expression that has been matched. Is this possible or no?