How can I match the 2 different groups in between the () in the below string
data foo (drop = DISCOUNT price RENAME = ( PROV_NM1= PROV_NM PROV_ST_NM1 = PROV_ST_NM) where = ( product = 'whizmo' and product < 10 )) bar( drop= DISCOUNT price rename= ( startDate = beginDate ) );
I need to match this to get 2 groups:
foo (drop = DISCOUNT price RENAME = ( PROV_NM1= PROV_NM PROV_ST_NM1 = PROV_ST_NM) where = ( product = 'whizmo' and product < 10 ))
bar( drop= DISCOUNT price rename= ( startDate = beginDate ) )
I have been trying it from quiet a few days now and has come up with this regex:
(?i)(data)\s+((\w+)(?=(\s*))(?:\4\w+))?\s*(\(((.|\n)*?)\);)?
It can be seen here: regex demo
It is working for most of the cases but doesn't give 2 separate groups in case of above example as it matches everything inside brackets in a single group.
I have tried a few recursive patterns too but sadly unable to figure it out. Any help or guidance on the same is appreciated. Thank you.