ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject <loadfile>,<filterchain>,<tokenfilter> with regular exp
Date Tue, 05 Apr 2005 06:39:56 GMT

to whom it may concern ...

Some time ago, i asked for a solution to extract a specific part
out of a txtfile using <loadfile>,<filterchain>,<tokenfilter> with
regular expressions.

In the meantime after putting aside a while, i've found a solution.
So if anybody has a similar problem, it may be helpful.

Situation = a given txtfile has to be scanned, format is :

...
... always 29 lines above i don't care for
* here at line 30 the part i want to extract starts
* there may follow one or n more lines
*
* ...
* ...
..Project - Repository under: <- the closing
CVS			      <- pattern
...
... more (blank) lines

The first line of the closing pattern contains some leading blanks.

I want to extract the part with the leading ' * '

my snippet =

<loadfile srcFile="path:/to my/foo.txt" property="myproperty">
        <filterchain>
<!-- load the whole file and throw away the first 29 lines -->
            <headfilter lines="-1" skip="29"/>
            <tokenfilter>
<!-- delete the lines with the closing pattern, replace with " " -->
                <replaceregex pattern="^.*(.+Project - .+der:|^CVS).*$"
replace=""/>
            </tokenfilter>
<!-- take out the remaining blank lines -->
            <deletecharacters chars="\t"/>
            <trim/>
            <ignoreblank/>
        </filterchain>
    </loadfile>  

The replaceregex ... replace="" works with and without flags="m".
I thought i had to use that, cause i go over some lines but it works
without.

Gilbert

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


Mime
View raw message