im trying to split a string
<div id = 'tostart'><button>todo </button>hometown todo </div>
with "to" as a keyword.
the problem is i do not have to split in between the tags and have to only split from outside the tags so if i split i get a result like
arr = ["<div id = 'tostart'><button>","do","</button>home","wn ","do </div>"]
is there a regex by using which it can be acheived.
Thanks in advance.
var splitText = text.match(/[\<].+?[\>]+|[^\s]+/g);but this splits from spaces and i need to split with a word