I would do it with .match() as follows:
'ThisIsTheStringToSplit'.match(/[AZ][az]+/g);
he will create such an array:
['This', 'Is', 'The', 'String', 'To', 'Split']
edit: since the string.split() method also supports regular expression, it can be achieved as follows
'ThisIsTheStringToSplit'.split(/(?=[AZ])/);
which will also solve the problem from the comment:
"thisIsATrickyOne".split(/(?=[AZ])/);
Teneff Oct 25 '11 at 11:05 2011-10-25 11:05
source share