I'm trying to get collection of string subsets from a string,
in this example pairs of <tags></tags>
Given the string:
<tag>abc</tag><tag>123</tag>
I want 2 groups:
<tag>abc</tag>
and <tag>123</tag>
That's easy as <tag>.*?</tag>
pattern.
But I would like it to be more precise.
Given the string:
<tag>abc</tag><tag><tag>123</tag>
I would it to omit the second <tag>
in the middle (because I'm searching for open and closing tags).
I want this result:
<tag>abc</tag>
<tag>123</tag>
I've tried to create a lookahead or lookbehind but no luck (I'm sure I'm using it wrong):
<tag>.*?(?<!<tag>)</tag>