A Little Help with a Regex?

This one has had me tied up for quite some time now. I have objects being returned in the following format:

I’m trying to extract everything between, for example, “” and “<\itemN>” as separate groups. Thought for sure this expression would work, but it isn’t:

r = new Regex("<(?:item\\d+>)\\r\\n([\\w\\W]+)</(\\1)");
			MatchCollection mc = r.Matches(result);
			foreach(Match match in mc)
			{
				Debug.Log("Matched:" + match.Groups[1].Value);
			}

What blatantly obvious thing am I managing to miss?

Finally spotted it :stuck_out_tongue: The problem is in the very early part of the string, “(?:item\d+>)”. As a non-capturing group, it never gets assigned to anything, thus the “\1” reference really refers to the group after it. Changing the line to this:

works completely as expected :slight_smile: Guess I just needed a little more time chuckle

Why bother with the regex at all? Why not just parse it as an XML string?