Regex Recursion: Nth Subpatterns
问题 I'm trying to learn about Recursion in Regular Expressions, and have a basic understanding of the concepts in the PCRE flavour. I want to break a string: Geese (Flock) Dogs (Pack) into: Full Match: Geese (Flock) Dogs (Pack) Group 1: Geese (Flock) Group 2: Geese Group 3: (Flock) Group 4: Dogs (Pack) Group 5: Dogs Group 6: (Pack) I know neither regex quite does this, but I was more curious as to the reason why the the first pattern works, but the second one doesn't. Pattern 1: ((.*?)(\(\w{1,}\)