Regex: Find all between parenthesis – including if parenthesis exists within
As Wiktor said, a dedicated parser is always the best option for this kind of processing.
However, if you still want to go with the regex route, you could simply add a positive lookahead that look for either a dot, a semi-colon or the end of the string.
\.(\w+)\((.*?)\)(?=\.|$|;)
You can test more cases here: regex101.com/r/QJ1h59/1
This is not perfect, though. If the regex inside the call is using a dot right after the parenthesis, the regex will not match the correct string. There will always be cases like this, you would be better off using a dedicated parser.
Read more here: Source link
