Reputation: 99
\w+\(([^\)]*)?\)+
This regex will match
abc(1,3,abs(4)
foo(1,3,abs(4)))
I want to match only
abc(1,3,abs(4))
Is it possible?
Upvotes: 1
Views: 48
Reputation: 627082
You can use the following regex:
^[a-z]+\((?>[^()]+|\((?<DEPTH>)|\)(?<-DEPTH>))*(?(DEPTH)(?!))\)$
It will match any string of characters from a to z in the beginning, and then a matching number of parentheses and everything inside them.
Tested in Expresso:
Upvotes: 2