ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Doug" <Doug.Dani...@GDC4S.Com>
Subject Retrieving a list of directory names from fileset without the ful ly qualified path
Date Thu, 01 Apr 2004 16:54:05 GMT
Hi everyone, I'm not sure this is the place to ask but I'm looking for a
regular expression that will convert an argument string that contains a list
of directories with fully qualified paths and I want to strip this down to
just the names of the directories without the rest of the path:

for example my string looks like this:

"-s /a/b/c -s /d/e/f" and I want to convert it to:
"-s c -s f"

Here is my test code, I'm using the ant-contrib library for the
<propertyregex> http://ant-contrib.sourceforge.net/, so point the libpath
property to where your ant-contrib jar is:


<project name="test" default="main">

<target name="main">

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
  <classpath>
    <pathelement location="${libpath}/ant-contrib-0.3.jar"/>
  </classpath>
</taskdef>

   <dirset id="homeDirs" dir="${user.home}" includes="*"/>

   <pathconvert pathsep=" -s " refid="homeDirs" property="arguments"/>

   <propertyregex property="arguments" global="true" override="true"
      input="${arguments}"
      regexp="(/[\w\.]+/*)+(\s)"
      replace="\1"
      defaultValue="failed" />
   
   <echo>ARGUMENTS: ${arguments}</echo>


</target>



</project>

~ Doug Daniels

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


Mime
View raw message