I have the following regex:
(\<parent\>(?s).*\<version\>).*(\<\/version\>(?s).*\<\/parent\>)
Which should work on the following text:
<name>CTR</name>
<!-- Parent -->
<parent>
<groupId>cxxdsds</groupId>
<artifactId>c222</artifactId>
<version>5.0.0-REPO</version>
</parent>
<scm>
I want to replace the string between <version> and <version>. But my sed does not work:
sed -i 's/(\<parent\>(?s).*\<version\>).*(\<\/version\>(?s).*\<\/parent\>)/\1xxxxxxx\2/g' pom.xml
Any ideas?
sedworks on a single line only by default,(?s)isn't supported (see Why does my regular expression work in X but not in Y? for details), etc. I'd also suggest to use tools likexmlstarletinstead ofsed