Georg-Johann Lay schrieb:
Hi,

can anyone assist me in solving this following quite trivial problem?

Given a path A and the current directory B=. derermine B relative to A. This is needed for prefixes in zipfileset.

In the special case that I am after B is a subdirectory (of some level) of A. So gettig the relative path B-A means that A and B look like this:

A=<sting1>
B=<sting1><string2>

I wasted hours to figure out how this could be achieved... The regex stuff is too complicated because dirs may contain special chars like blanke, ., \, /, -, $ and even *.

How can I easily remove the prexix A from B? I bet it is a one-liner.

Hallo again. Eventuelly the time was not wasted. I am using the following code. It is not exactly removing a prefix; it's a little bit more:

<macrodef name="set">
    <attribute name="property" />
    <attribute name="string" />
    <sequential>
        <property name="@{property}" value="@{string}"/>
    </sequential>
</macrodef>

<tempfile property="prefix.file" />

<macrodef name="unprefix">
    <attribute name="property"/>
    <attribute name="prefix"/>
    <attribute name="string"/>
    <sequential>
<echo message=".string.suff...@{property}=!!@{string}" file="${prefix.file}" />
        <replace file="${prefix.file}" token="=...@{prefix}" value="=!!" />
        <replace file="${prefix.file}" token="\" value="/" />
        <replaceregexp file="${prefix.file}" match="//*"   replace="/" />
        <replaceregexp file="${prefix.file}" match="=!!/*" replace="=" />
        <property file="${prefix.file}" />
<property name="@{property}" value="${.string.suff...@{property}}"/>
        <delete file="${prefix.file}" deleteonexit="true" />
    </sequential>
</macrodef>

Maybe someone finds is useful.

Grüß, Georg-Johann

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to