the interpretation of Bill is correct. In the meantime I've played a little bit with the "RegEx Coach":

1. Names can be found with: <Test>(.*?)</Test> 2. Tokens can be found with: \{(.*?)\}

Problem: Is it possible to combine both expressions (1 AND 2), that only a Name (e.g. Name1) with x Tokens (e.g. Token1, Token2) will be found and then the next Name (e.g. Name3) with x Tokens (e.g. Token3) and so on?

I cannot think of a way to do the whole job with one regex. (It seems to require a variable length look-ahead assertion which is not available in perl) Another approach is to use a regex to extract each Name and all the text that goes 'with' it. Use a second regex to extract the Token(s) from each block of text.

UPDATE: Better Solution

An even better solution is to use perl's IO to break your input into logical blocks:

We have already told you that a perl regular expression is not the right tool for this job. You are in the position of someone asking how to open a can of beans with a screwdriver. It seems possible, but not easy. There may even be a clever method that works most of the time, but sometimes produces a very undesirable result.

Now you tell us that we can use a "Sub-Regular expression". This term is not defined in perl documentation. How can we help without knowing more about your tools? Good Luck, Bill