jones jones - 2 months ago 6
PHP Question

How to get string between the last nested `(` , and `)`?

I have some MySQL statement like below:

GROUP_CONCAT(CONCAT_WS("=",DATE_FORMAT(ca.`date`,'%Y-%m-%d'),sa.`precence`)) as attendence


Above statement is a sample.

I want to get everything between the most deeply nested parentheses. In the above statement this is
ca.date,'%Y-%m-%d'
.

Question

How to do that with regex?

Answer

You can try this regex /(\([^\(\)]+\))/

DEMO