I am new to Python, I have a pipe delimited file and I want to to replace characters enclosed in single quotes with '*' which are present in the last column/4th column.
abc|123|xyz|456|select * from table emp where custname='John'
xyz|123|'John'|789|select * from table emp
'John'|456|abc|123|select abc from table emp
In the above example, you can see 'John' in single quote. I want to mask 'John' with '*'. In the second and third rows, you can see 'John' in single quotes, I do not want to mask it because those are not in the last column.
My requirement is to mask data which are in single quotes in the last column.
Expected output:
abc|123|xyz|456|select * from table emp where custname='*'
xyz|123|'John'|789|select * from table emp
'John'|456|abc|123|select abc from table emp