You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Felix Dorner <FD...@zed.com> on 2009/03/09 12:51:53 UTC

Trim leading spaces line by line

Hey,

I prefer my xml files to look nice, so I indent multi-line-echoes (these go to a file). Is there a simple ant way to remove all the spaces that were caused by the indentation afterwards?

Felix

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


RE: Trim leading spaces line by line

Posted by Harnack Frank <Fr...@bitmarck.de>.
Hello Francis,

first I thought, you were right, but it works with "\s*".

"\s+" would not.

But "^\s+" or "^\s*" works too.

Regards

Frank

-----Original Message-----
From: Francis Galiegue [mailto:fge@one2team.com] 
Sent: Tuesday, March 10, 2009 9:19 AM
To: Ant Users List
Subject: Re: Trim leading spaces line by line

Le mardi 10 mars 2009, Harnack Frank a écrit :
> Hello Felix,
> 
> try this:
> 
> <replaceregexp
> 	file="xyz.txt"
> 	match="\s*"

Err... "^\s*" would be better. If there's no leading space, the first series of spaces will be replaced by nothing instead.


-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 6 83 87 78 75
Tel : +33 (0) 1 78 94 55 52
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

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


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


Re: Trim leading spaces line by line

Posted by Francis Galiegue <fg...@one2team.com>.
Le mardi 10 mars 2009, Harnack Frank a écrit :
> Hello Felix,
> 
> try this:
> 
> <replaceregexp
> 	file="xyz.txt"
> 	match="\s*"

Err... "^\s*" would be better. If there's no leading space, the first series 
of spaces will be replaced by nothing instead.


-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 6 83 87 78 75
Tel : +33 (0) 1 78 94 55 52
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

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


Re: Remove trailing spaces from a string?

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
Sorry - type-o...

PropertyRegex - its a link under the Property Tasks:

http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html


On Mon, 22 Jun 2009, Scott Stark wrote:

>> Ant Contrib has a PropertyRedgex task you can use...
>
> Sorry, I don't see anything called that in ant-contrib. Is there another
> name for it?
>
> thanks,
> Scott
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

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

Architect Keros          http://sourceforge.net/projects/keros

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


Re: Remove trailing spaces from a string?

Posted by Scott Stark <ss...@us.ibm.com>.
> Ant Contrib has a PropertyRedgex task you can use...

Sorry, I don't see anything called that in ant-contrib. Is there another
name for it?

thanks,
Scott

Re: Remove trailing spaces from a string?

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
Ant Contrib has a PropertyRedgex task you can use...

Or you could definitely do something with scripting...like beanshell...

On Mon, 22 Jun 2009, Scott Stark wrote:

>
> Hi all, I see Ant tasks that can do string substitution in a file. Is there
> any way to do that in a simple string? I want to remove trailing spaces
> from property values.
>
> The reason I ask is that we use properties files to specify property values
> such as file names. Occasionally someone will put an extra space at the end
> of a file name, which is impossible to see in a text editor, but the extra
> space can cause the build to fail.
>
> Thanks,
>
> Scott Stark

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

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

Architect Keros          http://sourceforge.net/projects/keros

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


Remove trailing spaces from a string?

Posted by Scott Stark <ss...@us.ibm.com>.
Hi all, I see Ant tasks that can do string substitution in a file. Is there
any way to do that in a simple string? I want to remove trailing spaces
from property values.

The reason I ask is that we use properties files to specify property values
such as file names. Occasionally someone will put an extra space at the end
of a file name, which is impossible to see in a text editor, but the extra
space can cause the build to fail.

Thanks,

Scott Stark

RE: Trim leading spaces line by line

Posted by Harnack Frank <Fr...@bitmarck.de>.
Hello Felix,

try this:

<replaceregexp
	file="xyz.txt"
	match="\s*"
	replace=""
	byline="true"
/>

Regards

Frank


-----Original Message-----
From: Felix Dorner [mailto:FDorner@zed.com] 
Sent: Monday, March 09, 2009 2:35 PM
To: Ant Users List
Subject: RE: Trim leading spaces line by line

I found the solution my self in the ant manual:

<move file="${source}" tofile="${dest}">
        <filterchain>
            <tokenfilter>
                 <deletecharacters chars="\t"/>
                   <trim/>
                   <ignoreblank/>
            </tokenfilter>
        </filterchain>
</move>

It would be nice to do this on-the-fly, so that source and dest are the
same. Is this possible somehow?

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


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


RE: Trim leading spaces line by line

Posted by Felix Dorner <FD...@zed.com>.
I found the solution my self in the ant manual:

<move file="${source}" tofile="${dest}">
        <filterchain>
            <tokenfilter>
                 <deletecharacters chars="\t"/>
                   <trim/>
                   <ignoreblank/>
            </tokenfilter>
        </filterchain>
</move>

It would be nice to do this on-the-fly, so that source and dest are the same. Is this possible somehow?

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