ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
Subject Re: [help] Search a string in a file
Date Mon, 27 Nov 2006 15:39:15 GMT
You can use the <loadfile> task to load a whole file into a property, 
then apply your regular expression.

Just curious...where are you getting the <regex> task?

Dharmesh Vyas wrote:
> 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.
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


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


Mime
View raw message