I am trying to unformat a XML to single line. (Using JAVA)
I trying to use following regex to replace.
input.replaceAll(">\\s+", ">").replaceAll("\\s+<", "<");
However, it also will remove the space in front and behind element. Which is unexpected.
For example:
Scenario 01
Before: <AAA>{space}{space}{space}</AAA>
After: <AAA></AAA>
Scenario 02
Before: <AAA>{space}{space}123{space}{space}</AAA>
After: <AAA>123</AAA>
Scenario 03
Before: <AAA>{space}A{space}B{space}C{space}</AAA>
After: <AAA>A{space}B{space}C</AAA>
Is there any way to unformat and avoid scenario above?