ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neo anderson <javadeveloper...@yahoo.co.uk>
Subject using RE with newline problem
Date Tue, 11 Mar 2008 15:13:00 GMT

I use ant script to load a file similar to build.properties. (its format
looks like 'key = value')

One of its value looks like key = 'value' (value surrounded with the single
quotes)

So I use filterchain to get rid of it, code snippet as follow:

        <loadfile srcfile="file.txt" property="temp.param">
                <filterchain>
                        <linecontains>
                                <contains value="key = "/>
                        </linecontains>
                        <tokenfilter>
                                <stringtokenizer delims="="/>
                                <replaceregex pattern="('{1})" replace=""/>
                                <replaceregex pattern="('{1})" replace=""/>
                                <replaceregex pattern="key" replace=""/>
                                <replaceregex pattern="${line.separator}"
replac
e="" /><!-- newly added line to eliminate new line or CR -->
                        </tokenfilter>
                        <tokenfilter>
                                <replacestring from="=" to=""/>
                        </tokenfilter>
                        <trim/>
                </filterchain>
        </loadfile>

However, after sending parameter to the ant task it fails. Then I discover
the value of temp.param contain the newline (or carriage return). The output
using '<echo message="[${temp.param}]"/>' is as follow:

     [echo] [value
     [echo] ]

The value I expect is [value] not [value\n]. 

I try to use '<replaceregex pattern="${line.separator}" replace="" />', but
it does not work at all.

What should I do in order to get rid of it.

-- 
View this message in context: http://www.nabble.com/using-RE-with-newline-problem-tp15976680p15976680.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Mime
View raw message