Currently I have found a regular expression to find any <tag></tag>
and it's contents.
<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>
If I write irrevelant <tag>content</tag> even more irrevelant
I get what I want which is the exact tag with it's content <tag>content</tag>
.
The issue arises when I try to use this on a nested tag which nests with itself, like:
<tag>gimme cookies<tag>gimme more cookies</tag></tag>
Unfortunately, this time I get:
<tag>gimme cookies<tag>gimme more cookies</tag>
Without the second closing tag.
How could I improve the regex to only find the start and end tag only and the contents between them, so I could nest to infinity and beyond?