maven replace regex replacement leading whitespace
I'm doing some replaceRegex rules and I'm attempting to replace some text with { } however the leading whitespace gets trimmed and doesn't get added.
I've tried numerous work arounds using unicode, cdata, escape codes, and they all get trimmed (or the formatter just breaks)
How the heck do i add a leading space in the replacement text?
<replaceRegex>
<name>collapseEmptyBlocks</name>
<searchRegex>(?s)[\s\r\n]*\{[\s\r\n]*\}</searchRegex>
<replacement> {}</replacement> <!-- why spotless remove the leading whitespace??? -->
</replaceRegex>
the problem here is XML, not Spotless. Use a character entity
<replacement> {}</replacement>
I've tried that and the formatter breaks completely and no longer formats files, (but no errors)
This was the work around I had to do for other who come across something similar
<replaceRegex>
<name>collapseEmptyBlocks</name>
<searchRegex>(?s)[\s\r\n]*\{[\s\r\n]*\}</searchRegex>
<replacement>__FORMATTER_SPACE__ { }</replacement>
</replaceRegex>
<replaceRegex>
<name>collapseEmptyBlocks</name>
<searchRegex>__FORMATTER_SPACE__</searchRegex>
<replacement></replacement>
</replaceRegex>
hmm, not sure then