Okay guys
here are my 2 strings
D:/path/to/project/js/folder/LVL1/LVL2/mylibrary.js
and
D:/path/to/project/js/folder/mylibrary.js
for the first I want to get /LVL1/LVL2
and
for the second i want to get a slash /
here is my regex ^.+js\/folder(\/[^\.]*[^\/])\/.+\.js+$
it works fine for the first but returns nothing for the second
this is to be used in an ant task (more specifically the jscomp
). Basically I want to compile every javascript file in the 'D:/path/to/project/js/folder/' and put the output somewhere else with the nested folders. Here's an excerpt of my ant task if it ever helps.
<target name="compileJS" description="minifier les fichier JS">
<taskdef name="jscomp"
classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${lib.dir}/thirdparty/closure-compiler/compiler.jar" />
<taskdef resource="net/sf/antcontrib/cpptasks/antlib.xml">
<classpath>
<pathelement location="${lib.dir}/thirdparty/ant-contrib/cpptasks.jar" />
</classpath>
</taskdef>
<echo message="Searching for files in ${basedir}\charte\js" />
<for param="filename">
<path>
<fileset dir="${basedir}/charte/js">
</fileset>
</path>
<sequential id="i">
<!-- This gets the filename without the directory path. -->
<basename property="file.@{filename}" file="@{filename}" />
<propertyregex property="file"
input="@{filename}"
regexp="\\"
replace="/"
override="true"
defaultvalue="@{filename}" />
<echo message=">...>...> input = ${file}"/>
<propertyregex property="directory.@{filename}"
input="${file}"
regexp="^.+js\/folder(\/[^\.]*[^\/])\/.+[\.js]+$"
select="\1"
casesensitive="false" override="true" />
<echo message=">...>...> directory = ${directory.@{filename}}"/>
<echo message="Compressing file ${file.@{filename}} in ${directory.@{filename}}" />
<jscomp compilationLevel="simple"
output="${build.dir}/charte/js/directory.@{filename}/${file.@{filename}}">
<sources dir="${base.dir}/charte/js/directory.@{filename}/">
<file name="${file.@{filename}}" />
</sources>
</jscomp>
</sequential>
</for>
</target>
Thanks