The use case is for reformatting xml. I currently have a snippet that looks like this:
<dependencies>
<dependency>
<groupId>
com.googlecode.java-diff-utils
</groupId>
<artifactId>
diffutils
</artifactId>
<version>
1.3.0
</version>
</dependency>
</dependencies>
I want it to look like this:
<dependencies>
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
So the case is that I want to match <tag></tag>
pairs that do not have additional pairs within them, something like this:
output.replaceAll("<{TAG}>\\s+([^<>])\\s+</{TAG}>",
"<{TAG}>($1)</{TAG}>")
where {TAG}
can be matched.