ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: Extracting values from a line of a file
Date Wed, 11 Apr 2007 06:31:41 GMT

-----Original Message-----
From: Maninder Singh (GR/EIL) [] 
Sent: Wednesday, April 11, 2007 6:47 AM
Subject: Extracting values from a line of a file

	I am trying to figure out a way to extract the values from a
line in a file. 

To be more precise; there is a file that contains lines containing the
following fields (separated by spaces / tabs):
Name		Age		Contact_Number

I want to search for a particular name in this file (which I guess can
be done by using the Ant "loadproperties" task) and extract the age
corresponding to that Name from the file. Is there a way to do this?

with  =

bsf.jar (Bean Scripting Framework)

in sight for ant, i.e. in %ANT_HOME%/lib

you may use <script>, something like =

txtfile given =

Joe	22	1234567
Jack	33	3456789
Homer	44	1231231

and then =

<?xml version="1.0"?>

<project name="bla" default="main" basedir=".">

    <!-- // Properties -->
    <property name="scanfor" value="Homer"/>
    <!-- Properties // -->

    <target name="depends">
        <script language="ruby">
            $project.setProperty "scanresult",b

    <target name="main" depends="depends">

        age of == ${scanfor} ==> ${scanresult}


** the second group of the regex = (\d{1,3}) means the age must contain
digit and has the limit of max three digits. Someone might be 100 years
not the normal case, but  maybe ;-)

Regards, Gilbert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message