I would like to parse the time expression hh:mm:ss.xxx (hours, minutes, seconds, milliseconds) in a .XML file. It should look something like that:
<condition property="illegal-tc">
<matches pattern="the_pattern" string="${timeCode}"/>
</condition>
What I need is the negate of the pattern \d{2}:\d{2}:\d{2}.\d{3}.
I tried by doing ^[\d{2}:\d{2}:\d{2}.\d{3}]$ but it doesn't work properly.
The [...] construct matches the set of characters between those [ and ]. To get a negative match you need the (?! ... ) "negative lookahead" construct.
The pattern ^(?!\d{2}:\d{2}:\d{2}\.\d{3}).*$ matches anything that is not "hh:mm:ss.fff".
Note that a single digit hour, or a fraction of less than 3 digits will still match!
I found out another solution: do the "legal-tc" and negate it in the fail condition with the unless tag like this:
<condition property="legal-tc">
<matches pattern="^\d{2}:\d{2}:\d{2}.\d{3}$" string="${timeCode}"/>
</condition>
<fail message="Illegal Time Code" unless="legal-tc"/>
Related
I'm looking for a way to make this code snippet work but with one of the three contains being true. So OR instead of AND.
<condition property="warningFilesFound">
<resourcecount when="greater" count="0">
<fileset id="warnings-fileset-id" dir="${target.dir}/xref" includes="**/*.warnings">
<contains text="requires "CHARACTER","RAW" or "COLUMN" for double-byte or multi-byte(UTF8) languages. (3619)"/>
<contains text="requires "CHARACTER" or "RAW" for double-byte languages. (2363)"/>
<contains text="requires "CHARACTER", "RAW", "COLUMN" or "FIXED" for double-byte or multi-byte(UTF8) languages. (3623)"/>
</fileset>
</resourcecount>
</condition>
Only one of the three contains should be true. In this code snippet all three contains must be true. Regular expression?
You should be able to wrap an <or> selector round the contain elements, something like this:
<fileset id="warnings-fileset-id" dir="${target.dir}/xref" includes="**/*.warnings">
<or>
<contains text="requires "CHARACTER","RAW" or "COLUMN" for double-byte or multi-byte(UTF8) languages. (3619)"/>
<contains text="requires "CHARACTER" or "RAW" for double-byte languages. (2363)"/>
<contains text="requires "CHARACTER", "RAW", "COLUMN" or "FIXED" for double-byte or multi-byte(UTF8) languages. (3623)"/>
</or>
</fileset>
I have a requirement with respect to ant loops.
It says I have 3 different text files each with say 3 lines (each line is a one word string for all files).
Now I need a foreach loop in Ant that reads all 3 files at same time for the first line in each file and stores the values accordingly as 3 different properties. This way for every single iteration of loop I can refer to a target where I can pass these properties for target execution.
The loop will hence run 3 times and execute that target 3 times one for each iteration.
Say for example I have the following sample code:-
<target name="read">
<loadfile property="file" srcfile="./dist/DB_Critical_Stub_Data.txt"/>
<loadfile property="fileversion" srcfile="./dist/version.txt"/>
<loadfile property="filecomponent" srcfile="./dist/component.txt"/>
<foreach list="${file},${fileversion},${filecomponent}" param="line,line1,line2" delimiter="${line.separator}" target="start-stub"/>
</target>
<target name="start-stub">
<property name="stub-name" value="${line}"/>
<property name="stub-version" value="${line1}"/>
<property name="stub-component" value="${line2}"/>
<startStub name="${stub-name}" version="${stub-version}" component="${stub-component"}/>
</target>
Any suggestions/help here would be highly appreciated.
I am trying to concat multiple files (say 15 txt files) to a single file at the same time by separate ant calls.
Say there are 15 concat() run at the same time.
However, the output file was not expected.
The data in the output file is corrupted.
Does anyone have idea to solve this problem?
Example:
Input 1:
a=1
b=2
c=3
Input 2:
d=4
e=5
f=6
Output:
a=1
b=2
d=4
e
c=3=5
f=6
You can do this with the concat task, which take a resource collection such as `filesets' as nested elements, allowing you to concatenate all the files in a single task call. Example:
<concat destfile="${build.dir}/output.txt">
<fileset file="${src.dir}/input1.txt" />
<fileset file="${src.dir}/input2.txt" />
</concat>
I have the following strings as input for scheduler file
Z:\cnt_development\cnt\test\Test-cases-blr\v80-WM\scheduler\FRQ\AUTO\sml-hr454\SRISM.xml
Z:\cnt_development\cnt\test\Test-cases-blr\v80-WM\scheduler\FRQ\AUTO\sml-lr454\Swap_MUL.xml
Z:\cnt_development\cnt\test\Test-cases-blr\v80-WM\scheduler\FRQ\AUTO\sml-lr456\Swap_MU.xml
I need to extract the complete part from v80-WM
i.e The regex must be able to select the following string
v80-WM\scheduler\FRQ\AUTO\sml-hr454\SRISM.xml
v80-WM\scheduler\FRQ\AUTO\sml-lr454\Swap_MUL.xml
v80-WM\scheduler\FRQ\AUTO\sml-lr456\Swap_MU.xml
Currently I am using the following regex where the regex finds the last occurence of "Q" in the above string and trimming for there and using workardoung to construct the above mentioned results.
<echo message="runpART ... Scheduler File ${schedulerFile}"/>
<propertyregex property="cfg.arg" input="${schedulerFile}" regexp="([^Q]*).xml" select="\1" casesensitive="false"/>
Need help in extracting string from "v80-WM....xml".
Some inputs will be helpful
That's good. The v80-WM gives you a fixed "starting point"
Using this as your regular expression should do it.
^.(v80-WM.)
What it means:
^.* match anything until you get to *the caret isn't really necessary, but I like making the reg exp more strict)
v80-WM
= .* then match the rest
The parens include the v80-WM name and everything that comes after so you don't have to reconstruct it.
I have an ant task which should compare two values for equality. If the two values are not equal, I'd like to fail:
<condition property="versionDoesNotMatch">
<not>
<equals arg1="applicationVersion" arg2="releaseNotesVersion"/>
</not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>
According to the ant output, both values, releaseNotesVersion and applicationVersion have the same value 1.7 but the condition always evaluates to true - which because of the not would mean, that the numbers are not equal. Which makes me wonder, if ant would have troubles comparing those kind of values ?
You're matching two literal strings in your example; these will never be equal and so your condition always evaluates to true. Assuming that your args are Ant properties, you need to evaluate the property values like this:
<condition property="versionDoesNotMatch">
<not>
<equals arg1="${applicationVersion}" arg2="${releaseNotesVersion}"/>
</not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>