ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Kucybała <kkucyb...@echo.fr>
Subject Re: How to escape characters in regexp strings?
Date Fri, 17 Aug 2007 13:59:49 GMT
This doesn't work either :o(

To show the bigger picture, I have a line in a php file, that looks like 
this:

// Choose your wassup host
define("WS_WASSUPHOST", "somehost.somedomain.net");

during build I need to be able to substitute this 
somehost.somedomain.net with another one that comes from a property file.

<
replaceregexp
file="${artifactsdir}/${label}/${env}/src/include/configuration_wassup.php"
match="define(\"WS_WASSUPHOST\" *, *\".*\");"			 
replace="define(\"WS_WASSUPHOST\","${dev.bck.mmc.ws_wassuphost}\");"
/>

This code fails with erros, the one I wrote previously doesn't work at 
all, the one You gave me as well, and neither does the version of the 
one above with double escaped double-quotes, which causes erros like this:

mmc.xml:84: Element type "replaceregexp" must be followed by either 
attribute specifications, ">" or "/>".

where line 84 is the one that starts with the word 'match'.

Can You tell me how to correct it? I'd appreciate greatly.

Best regards,
Krzysztof Kucybała

Amarjit Jutla wrote:
> You must also escape the \ character
> 
> <
> replaceregexp 
> file="${artifactsdir}/${label}/${env}/src/include/configuration_wassup.php"
> match='define(\\"WS_WASSUPHOST\\" *, *\\".*\\");'				 
> replace='define(\\"WS_WASSUPHOST\\", \\"${dev.bck.mmc.ws_wassuphost}\\");'
> />
> 
> -----Original Message-----
> From: Krzysztof Kucybala [mailto:kkucybala@echo.fr]
> Sent: Friday, August 17, 2007 9:30 AM
> To: user@ant.apache.org
> Subject: How to escape characters in regexp strings?
> 
> 
> Hi,
> 
> I have a problem. I'm trying to have ant substitute something in a few 
> files. Here's the sample:
> 
> <
> replaceregexp 
> file="${artifactsdir}/${label}/${env}/src/include/configuration_wassup.php"
> match='define("WS_WASSUPHOST" *, *".*");'				 
> replace='define("WS_WASSUPHOST", "${dev.bck.mmc.ws_wassuphost}");'
> />
> 
> This does not give me any errors, but it doesn't do anything. When I 
> tried the same with " instead of ' in the match and replace attributes, 
> obviously I'd need to escape other occurrences of " in the text. How do 
> I do that? \" doesn't work :o( I will appreciate any help.
> 
> Best regards,
> Krzysztof Kucybała
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message