With this C# regex, you can easily match/Parse Nested HTML tags.
Example input:
someTitle
SomeHeader
anotherHeader
HelloWorld
Output:
anotherHeader
HelloWorld
string pattern = $@"{ startP }((?'nested'{ openP })|{ closeP }(?'-nested')|\w\W]?){ closeP }";
*'StartP' (Must include open tag), example: <div id="target"
*'openP' example: <div
*'closeP' example: </div
References:
[In Depth with RegEx Matching Nested Constructions
In Depth with .NET RegEx Balanced Grouping
Regular expression matches closed HTML tags (nesting is supported)