Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created June 9, 2010 18:26
Show Gist options
  • Save indexzero/431925 to your computer and use it in GitHub Desktop.
Save indexzero/431925 to your computer and use it in GitHub Desktop.
var html = "<div><hr>foo<div>bar</div></div>";
var c = -1;
html = html.replace(/\<([^<\>]*)\>/g, function(str, r) {
if(r.indexOf("/") === -1) {
c++;
return "[\"" + r + ((c == 0) ? "\"," : "\"],");
}
else {
return "]";
}
});
html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment