How to remove duplicate white spaces (including tabs, newlines, spaces, etc...) in a string using Java but not to remove duplicate white spaces in " " and ' ' quoted values within the input sptring ?
Input :
Select *
from emp
where name = 'sanjiv singh'
and address = "ABC sector - 11";
Expected output :
Select * from emp where name = 'sanjiv singh' and address = "ABC sector - 11";
I have tried it in the way: Iterated input string from start to end and ate duplicate white spaces only pointer is not between quoted value.
It is working fine in my case.
Is there any other way to achieve it ?