Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function countDivs(html) {
  2.     console.log(html.match(/<div/g).length);
  3. }
  4.  
  5. countDivs('<!DOCTYPE html>\n' +
  6. '<html>\n' +
  7. '<head lang="en">\n' +
  8. '<meta charset="UTF-8">\n' +
  9. '<title>index</title>\n' +
  10. '<script src="/yourScript.js" defer></script>\n' +
  11. '</head>\n' +
  12. '<body>\n' +
  13. '<div id="outerDiv">\n' +
  14. '<div\n' +
  15. 'class="first">\n' +
  16. '<div><div>hello</div></div>\n' +
  17. '</div>\n' +
  18. '<div>hi<div></div></div>\n' +
  19. '<div>I am a div</div>\n' +
  20. '</div>\n' +
  21. '</body>\n' +
  22. '</html>');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement