javascript - spliting the string into desired format and creating an array out of it -


i have string want break after every </div> , insert array. following string.

"<div title='run of network' id='525000000'>run of network</div> <div title='3dserver11' id='525001499'>3dserver11</div>" 

i thought of using split() function, since not comma separated string, not able understand how should break string , generate array. in array want single single div entries like:

a[0] = <div title='run of network' id='525000000'>run of network</div> a[1] = <div title='3dserver11' id='525001499'>3dserver11</div>" 

can 1 help? in advance.

i wouldn't suggest split html strings split method or parse regular expressions. better operate elements dom methods:

var str = "<div title='run of network' id='525000000'>run of network</div>\            <div title='3dserver11' id='525001499'>3dserver11</div>",     div = document.createelement("div"),     arr = [];  div.innerhtml = str; arr = array.prototype.slice.call(div.getelementsbytagname("div")); arr = arr.map(function(e) { return e.outerhtml; });  // create strings                                                      // out of dom elements console.log(arr); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -