I'm trying to separate a string with html and non-html in it into two strings.
My javascript string is:
<span>1x</span> Front-line zero tolerance productivity
I want this to be separated into two variables
var quantity = "1x";
var name = "Front-line zero tolerance productivity";
Split when a <span> or </span> tag is found.
string = "<span>1x</span> Front-line zero tolerance productivity"
tokens = string.split(/<\/?span>/); // returns ["", "1x", " Front-line zero tolerance productivity"]
var quantity = tokens[1] // "1x"
var name = tokens[2]; // "Front-line zero tolerance productivity"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With