Split string with inner and outer delimeters in Javascript -


in javascript code, have string this:

"1943[15]43[67]12[32]" 

i want return array this:

["1","9","4","3","15","4","3","67","1", 2","32"] 

that is, want separate every character, except numbers inside brackets, want preserve 1 element.

is there elegant way this?

var str = '1943[15]43[67]12[32]',     matches = str.match(/\d|\[\d+\]/g);  (var = 0, matcheslength = matches.length; < matcheslength; i++) {     matches[i] = matches[i].replace(/\d/g, ''); };  console.log(matches); // ["1", "9", "4", "3", "15", "4", "3", "67", "1", "2", "32"] 

jsfiddle.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -