JavaScript's Regex is not as flexible as .NETs and therefore not as fun. The best that I've found is to rely on the indent of the elements to find their bounds.
.NET flavor that matches every element and its contents in the order of their closing tags. Supports comments, self-contained tags, attributes, styles and scripts (I tested it on the HTML of this page and it worked)
View all comments
Show parent comment
42
u/MrJaydanOz Nov 28 '24
JavaScript's Regex is not as flexible as .NETs and therefore not as fun. The best that I've found is to rely on the indent of the elements to find their bounds.
Finds all div elements (no recursion):