Index: src/main/org/apache/tools/ant/taskdefs/defaults.properties
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
retrieving revision 1.86
diff -c -b -r1.86 defaults.properties
*** src/main/org/apache/tools/ant/taskdefs/defaults.properties	2001/08/01 10:43:58	1.86
--- src/main/org/apache/tools/ant/taskdefs/defaults.properties	2001/08/02 04:55:39
***************
*** 119,124 ****
--- 119,125 ----
  jpcoverage=org.apache.tools.ant.taskdefs.optional.sitraka.Coverage
  jpcovmerge=org.apache.tools.ant.taskdefs.optional.sitraka.CovMerge
  jpcovreport=org.apache.tools.ant.taskdefs.optional.sitraka.CovReport
+ regexpreplace=org.apache.tools.ant.taskdefs.optional.RegexpReplace
  
  # deprecated ant tasks (kept for back compatibility)
  javadoc2=org.apache.tools.ant.taskdefs.Javadoc
Index: src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java,v
retrieving revision 1.3
diff -c -b -r1.3 RegexpPatternMapper.java
*** src/main/org/apache/tools/ant/util/RegexpPatternMapper.java	2000/11/29 11:50:02	1.3
--- src/main/org/apache/tools/ant/util/RegexpPatternMapper.java	2001/08/02 04:55:39
***************
*** 73,79 ****
      protected StringBuffer result = new StringBuffer();
  
      public RegexpPatternMapper() throws BuildException {
!         reg = (new RegexpMatcherFactory()).newRegexpMatcher();
      }
      
      /**
--- 73,79 ----
      protected StringBuffer result = new StringBuffer();
  
      public RegexpPatternMapper() throws BuildException {
!         reg = RegexpMatcherFactory.getRegexpMatcher();
      }
  
      /**
Index: src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java,v
retrieving revision 1.1
diff -c -b -r1.1 JakartaOroMatcher.java
*** src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java	2000/11/28 16:01:12	1.1
--- src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java	2001/08/02 04:55:39
***************
*** 74,81 ****
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
          try {
!             this.pattern = comp.compile(pattern);
          } catch (MalformedPatternException e) {
              throw new BuildException(e);
          }
--- 74,97 ----
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
+         setPattern(pattern, false, false);
+     }
+ 
+     /**
+      * Set the regexp pattern from the String description.
+      */
+     public void setPattern(String pattern, boolean multiline, boolean ignorecase) throws BuildException {
          try {
!             int options = 0;
! 
!             if (multiline) {
!                 options |= Perl5Compiler.MULTILINE_MASK;
!             }
!             if (ignorecase) {
!                 options |= Perl5Compiler.CASE_INSENSITIVE_MASK;
!             }
! 
!             this.pattern = comp.compile(pattern, options);
          } catch (MalformedPatternException e) {
              throw new BuildException(e);
          }
***************
*** 93,98 ****
--- 109,120 ----
       */
      public boolean matches(String argument) {
          return reg.contains(argument, pattern);
+     }
+ 
+     /** @see RegexgMatcher#substitute */
+     public String substitute(String substin, String substitution)
+     {
+         return Util.substitute(reg, pattern, new Perl5Substitution(substitution), Util.SUBSTITUTE_ALL);
      }
  
      /**
Index: src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java,v
retrieving revision 1.2
diff -c -b -r1.2 JakartaRegexpMatcher.java
*** src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java	2000/11/28 16:01:12	1.2
--- src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java	2001/08/02 04:55:39
***************
*** 73,81 ****
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
          try {
              this.pattern = pattern;
!             reg = new RE(pattern);
          } catch (RESyntaxException e) {
              throw new BuildException(e);
          }
--- 73,98 ----
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
+         setPattern(pattern, false, false);
+     }
+ 
+     /**
+      * Set the regexp pattern from the String description.
+      */
+     public void setPattern(String pattern, boolean multiline, boolean ignorecase)
+         throws BuildException {
          try {
+             int options = 0;
+ 
+             if (multiline) {
+                 options |= RE.MATCH_MULTILINE;
+             }
+             if (ignorecase) {
+                 options |= RE.MATCH_CASEINDEPENDENT;
+             }
+ 
              this.pattern = pattern;
!             reg = new RE(pattern, options);
          } catch (RESyntaxException e) {
              throw new BuildException(e);
          }
***************
*** 93,98 ****
--- 110,121 ----
       */
      public boolean matches(String argument) {
          return reg.match(argument);
+     }
+ 
+     /** @see RegexgMatcher#substitute */
+     public String substitute(String substin, String substitution)
+     {
+         return reg.subst(substin, substitution);
      }
  
      /**
Index: src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java,v
retrieving revision 1.1
diff -c -b -r1.1 Jdk14RegexpMatcher.java
*** src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java	2001/07/11 08:03:11	1.1
--- src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java	2001/08/02 04:55:40
***************
*** 75,82 ****
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
          try {
!             this.pattern = Pattern.compile(pattern);
          } catch (PatternSyntaxException e) {
              throw new BuildException(e);
          }
--- 75,100 ----
       * Set the regexp pattern from the String description.
       */
      public void setPattern(String pattern) throws BuildException {
+         setPattern(pattern, false, false);
+     }
+ 
+     /**
+      * Set the regexp pattern from the String description.
+      */
+     public void setPattern(String pattern, boolean multiline, boolean ignorecase)
+         throws BuildException {
          try {
!             int options = 0; // assume default options is 0
! 
!             if (multiline) {
!                 options |= Pattern.MULTILINE;
!             }
!             if (ignorecase) {
!                 options |= Pattern.CASE_INSENSITIVE;
!             }
! 
!             this.pattern = Pattern.compile(pattern, options);
! 
          } catch (PatternSyntaxException e) {
              throw new BuildException(e);
          }
***************
*** 94,99 ****
--- 112,123 ----
       */
      public boolean matches(String argument) {
          return pattern.matcher(argument).find();
+     }
+ 
+     /** @see RegexgMatcher#substitute */
+     public String substitute(String substin, String substitution)
+     {
+         return pattern.matcher(substin).replaceAll(substitution);
      }
  
      /**
Index: src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java,v
retrieving revision 1.1
diff -c -b -r1.1 RegexpMatcher.java
*** src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java	2000/11/28 15:10:37	1.1
--- src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java	2001/08/02 04:55:40
***************
*** 70,75 ****
--- 70,80 ----
      public void setPattern(String pattern) throws BuildException;
  
      /**
+      * Set the regexp pattern from the String description.
+      */
+     public void setPattern(String pattern, boolean ignorecase, boolean multiline) throws BuildException;
+ 
+     /**
       * Get a String representation of the regexp pattern
       */
      public String getPattern();
***************
*** 78,83 ****
--- 83,96 ----
       * Does the given argument match the pattern?
       */
      public boolean matches(String argument);
+ 
+     /**
+      * substitute any matches of the pattern in the given string with another string.
+      * @param substin the string to perform substitutions on
+      * @param substitution the string to substitute for matches
+      * @return substin with all occurences of the pattern substituted with substitution
+      */
+     public String substitute(String substin, String substitution);
  
      /**
       * Returns a Vector of matched groups found in the argument.
Index: src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java,v
retrieving revision 1.2
diff -c -b -r1.2 RegexpMatcherFactory.java
*** src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java	2001/07/11 08:03:11	1.2
--- src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java	2001/08/02 04:55:40
***************
*** 62,77 ****
   * <code>ant.regexp.matcherimpl</code> and the classes
   * available.
   * 
-  * <p>In a more general framework this class would be abstract and
-  * have a static newInstance method.</p>
   *
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> 
   */
  public class RegexpMatcherFactory {
  
!     public RegexpMatcherFactory() {}
  
!     public RegexpMatcher newRegexpMatcher() throws BuildException {
          String systemDefault = System.getProperty("ant.regexp.matcherimpl");
          if (systemDefault != null) {
              return createInstance(systemDefault);
--- 62,83 ----
   * <code>ant.regexp.matcherimpl</code> and the classes
   * available.
   *
   *
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   */
  public class RegexpMatcherFactory {
  
!     private final static RegexpMatcherFactory INSTANCE = new RegexpMatcherFactory();
  
!     private RegexpMatcherFactory() {}
! 
!     public static RegexpMatcher getRegexpMatcher() throws BuildException
!     {
!         return INSTANCE.newRegexpMatcher();
!     }
! 
! 
!     protected RegexpMatcher newRegexpMatcher() throws BuildException {
          String systemDefault = System.getProperty("ant.regexp.matcherimpl");
          if (systemDefault != null) {
              return createInstance(systemDefault);
