Source string: " LTRIM(RTRIM(AB.ITEM_ID)) AS ITEM_NUMBER, "
convert LTRIM RTRIM to just TRIM and remove extra right parentheses. I need this to be converted to " TRIM(AB.ITEM_ID) AS ITEM_NUMBER, "
Have many sql files which are written long back and need to be corrected as part of platform migration. this source string could be tons of places in each sql. I tried doing line.replace('LTRIM(RTRIM', 'TRIM') works but leaves with the extra right bracket. I want the extra brackget also to be removed at oneshot sample inputs:
1.REPLACE(LTRIM(RTRIM(NVL(AB.ITEM_SHORT_DESC,AB.ITEM_DESC))),',','') AS SHORT_DESC
2.LTRIM(RTRIM(AB.ITEM_ID))** AS ITEM_NUMBER,**
please be advised the input is a full file as string and can have multiple occurrences and not just one line with this LTRIM(RTRIM . Sure have to use some regex etc.
I am using python 3.8.2