I'm making a syntax highlight, with live code editor.
here de example of string code:
// before.
var x = 'person + arthur' + "family + all";
// after.
var x = 'person + arthur' <span style="color:red;">+</span> "family + all";
Im using:
var x = string.replace(/\+/g,'<span style="color: red;">+</span>'); // but this replace all.
I need replace only outside of single quotes and double quotes.
Im using a Get .innerText, for avoid conflicts in the regex.