Great looking solutions you guys, but I actually have a few additional design constraints:
1. No perl code embedded in the regex. After demonstration of the prototype in perl, it will be implemented in the product using Java, so it must be compatible with the Java regex engine.
2. The regex should only have to be compiled once, so no rewriting of the regex string after starting to iterate through the matches.
Whoops -- there's you're last reply. I didn't see it when I was answering your last one.
I'm going to have to throw in the towel -- what you're asking for is out of my league! Isn't there some way you could do the equivalent thing in Java code though?
Anyway, good luck!