Very tricky with regex. Probably better to use Ant XSLT task on the Maven file
Main Topics
Browse All TopicsI have the following XML configuration in a pom.xml that's used by Maven.
<plugin>
<artifactId>maven-war-plug
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>
**/hibernate.cfg.xml,**/sq
</dependentWarExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.appfuse</grou
<artifactId>maven-warpath-
<version>1.0-m5-SNAPSHOT</
<extensions>true</extensio
<executions>
<execution>
<goals>
<goal>add-classes</goal>
</goals>
</execution>
</executions>
<configuration>
<warpathExcludes>
applicationContext-resourc
hibernate.cfg.xml,jdbc.pro
sql-map-config.xml
</warpathExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo
<artifactId>appfuse-maven-
<version>${appfuse.version
<configuration>
<genericCore>${amp.generic
<fullSource>${amp.fullSour
</configuration>
</plugin>
I'm writing a custom program to parse this file and remove the <plugin> block for the "maven-warpath-plugin".
The following regular expression works, but it grabs all the XML until the last "</plugin>" in the file - rather than just the next one.
<artifactId>maven-warpath-
Any ideas how to change it so it doesn't match the last one, just the next one? Also, I'd like to capture the XML preceding the <artifactId> referenced in the pattern above?
I'm using Java and Ant's ReplaceRegexp Task (http://ant.apache.org/man
Thanks,
Matt
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Using the following does achieve my desired effect:
<artifactId>maven-warpath-
However, it leaves the beginning of the <plugin> configuration:
<plugin>
<groupId>org.appfuse</grou
Is there any way to include this in the pattern? I tried the following, but it doesn't work.
<plugin>\\n\\s<groupId>org
Business Accounts
Answer for Membership
by: amit_gPosted on 2007-05-20 at 23:19:45ID: 19125472
Try
plugin</ar tifactId>( ?s:.)*?</p lugin>
plugin<\/a rtifactId> (\s|.)+?<\ /plugin>
<artifactId>maven-warpath-
or
<artifactId>maven-warpath-