The code below allows <propertycopy name="x" from="y" regexp="s/a/b/g"/>.

Personally I find it very handy, and maybe others will too.

Cheers,
Mike.

----------------------------

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.oro.text.perl.Perl5Util;

public class PropertyCopy extends Task
{
    private String name;
    private String from;
    private boolean silent;
    private String regexp;

    /***
     * Default Constructor
     */
    public PropertyCopy()
    {
        super();
        this.name = null;
        this.from = null;
        this.regexp = null;
        this.silent = false;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public void setFrom(String from)
    {
        this.from = from;
    }

    public void setSilent(boolean silent)
    {
        this.silent = silent;
    }

    public void setRegexp(String regexp) {
        this.regexp = regexp;
    }

    public void execute()
        throws BuildException
    {
        if (name == null)
            throw new BuildException("Missing the 'name' attribute.");

        if (from == null)
            throw new BuildException("Missing the 'from' attribute.");

        String value = getProject().getProperty(from);

        if (value == null && ! silent)
            throw new BuildException("Property '" + from + "' is not defined.");

        if (value != null)
        {
            if ( regexp != null ) {
                value = doRegexp(value);
            }
            if (getProject().getUserProperty(name) == null)
                getProject().setProperty(name, value);
            else
                getProject().setUserProperty(name, value);
        }
    }

    private String doRegexp(final String value) {
        org.apache.oro.text.perl.Perl5Util perl = new Perl5Util();
        return perl.substitute(regexp,value);
    }
}