Hi,
use a <loadfile> combined with a filterchain, f.e. =
test.txt
abcd
xyz
what
why
Rebuild All: 1 failed, 0 skipped
new world
Rebuild All: 0 failed, 0 skipped
techno
<target name="depends">
<loadfile property="failure.nos" srcfile="Y:/test.txt">
<filterchain>
<linecontainsregexp>
<regexp pattern='Rebuild.*'/>
</linecontainsregexp>
</filterchain>
</loadfile>
</target>
<target name="main" depends="depends">
<echo>$${failure.nos} == ${line.separator}${failure.nos}</echo>
</target>
depends:
main:
[echo] ${failure.nos} ==
[echo] Rebuild All: 1 failed, 0 skipped
[echo] Rebuild All: 0 failed, 0 skipped
BUILD SUCCESSFUL
Total time: 359 milliseconds
Regards, Gilbert
-----Original Message-----
From: Dharmesh Vyas [mailto:[EMAIL PROTECTED]
Sent: Monday, November 27, 2006 4:31 PM
To: [email protected]
Subject: [help] Search a string in a file
Hello all,
Here is what I am trying to implement to identify if my build process
has
failed.
For e.g this are the contents of the input file:
abcd
xyz
what
why
Rebuild All: 1 failed, 0 skipped
new world
Rebuild All: 0 failed, 0 skipped
techno
- Read this file to search for string "Rebuild All: 1 failed, 0 skipped"
and
see how many failures were there.
*The problem I am finding is*
- I am using regex to perform the pattern matching to check if there
were
any failures. Since the line could appear any no of times in the file, i
don't know how shall I implement that.
- Regex takes a string as an input, how can I pass a file to it or there
is
any other task that I shall use.
Here is how I am using regex for an input string.
<target name="searchstring>
<regex property="failure.nos"
input="Rebuild All: 0 succeeded, 1 failed, 0 skipped"
regexp="Rebuild All: ([0-9]) failed, ([0-9])"
select="\1"
casesensitive="false" />
<echo>${failure.nos}</echo>
</target>
Thanks a lot in advance,
- Dharmesh.
note: I am sorry if it's a stupid question but I am a novie user/memeber
of
this group.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]