The PCRE pattern (([^()]+)\(((?R)?)\))
matches your input as follows:
- group 1:
Match1(Match2())
- group 2:
Match1
- group 3:
Match2()
Note: Python’s regex module, Perl, .NET, Ruby 2.0 and PHP support recursive patterns. Other popular languages like JavaScript, Ruby <1.9 and Java don’t. See: https://www.regular-expressions.info/recurse.html
3
solved Match between brakets that may contain other brakets [duplicate]