ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rinehart, Raleigh" <raleigh.rineh...@ti.com>
Subject RE: How to replace a \ with &#x1a; Or how do I replace anything with &
Date Fri, 27 Feb 2009 19:41:49 GMT
> I am trying to replace a \ with the character sequence &#x1a;
> Don't ask why! Im not sure I know just yet.
> 
> If I use this method:
> 
> <replace file="${dir}\${file}"
> token="\" value="&#x5c;" summary="true"> </replace>
> 
> it just replaces \ with \
> 
> 
> If I use this method:
> 
> <replaceregexp file="${dir}\${file}" match="\" replace="&#x5c;"
> byline="true"/> I get this error:
> Unexpected internal error near index 1
> 
> If I try to build up the sequence with multiple replaces, Ant won't let me
> insert an & into the file, I get this error:
> The entity name must immediately follow the '&' in the entity reference.
> Or
> "&#x1a" is an invalid XML character.
> 
> This is running ant on windows. Would the results be different from unix?
> 
> Would sed work from unix? what is the best sed-like app for windows?
> 
> Thanks
 
Can't use & directly in XML as it is a special char.  Need to use the entity ref so the
parser does what you want.


This should work for you:
<replace file="test" token="\" value="&amp;#x5c;" summary="true"/>


Hope this helps,
-raleigh

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


Mime
View raw message