will remain the same. Meaning any combination of the string with any text should not matter. The keys are the delimiters.
Hello, I am your <type1> and <type2>!
array = Hello, I am your
array = <type1>
array = and
array = <type2>
array = !
Best How To :
I am not sure whether you are looking to do this with HTML context since you have tagged the question, if so, I would not do this and look for a better way such as using a parser.
You could split on preceding whitespace and the delimiters like this.
var r = 'Hello, I am your <type1> and <type2>!'.split(/\s*(<[^>]*>)\s*/);
console.log(r); //=> [ 'Hello, I am your', '<type1>', 'and', '<type2>', '!' ]
If you want to keep the preceding whitespace and only split on the delimiters.
var r = 'Hello, I am your <type1> and <type2>!'.split(/(<[^>]*>)/);
console.log(r); //=> [ 'Hello, I am your ', '<type1>', ' and ', '<type2>', '!' ]