How to extract a specified field of comparator from a comparison expression

I have a SQL like ” where age = 1 and name = ‘xxx’ and ds >= ‘2021-11-11’, how to extact the comparison of field ‘ds’, like ds > ‘2021-11-11’ ?

even more, i need to analyze complex sql like : where age = 2 and ( ds = ‘2021-11-11’ or name = ‘xxx’ ) or ds = ‘2021-12-12’.

is there a algorithm or code help me ?