jones jones - 2 months ago 8
PHP Question

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

I have some mysql statement like bellow:

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


Above statement is a sample, what i would to do is, to take every thing between the last nested parentheses
(ca.date,'%Y-%m-%d')
.
How to do that with regex or another ways ?

Answer

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

DEMO