I have a variable that can store plain text and tags <script>
and <img>
, delimited by (';')
. To separate information, I use the split(';')
method. It works fine for texts and <img>
, however, with <script>
gives error ( SyntaxError: unterminated string literal
), I imagine it due to the various semicolons inside it. I would like a solution that works for and <img>
, and for <script>
.
var test = 'texto1; texto2'; // Sem problema
var test = '<img src="imagem.jpg" />; <img src="imagem2.jpg" />'; // Sem problema
var test = '<script type="text/javascript">var a = "valor1";</script>; <script type="text/javascript">var b = "valor2";</script>'; // Com problema
console.log(test.split(';'));