You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Pankaj Arora01 <Pa...@infosys.com> on 2009/04/16 10:24:56 UTC

Replaceregexp in ANT

HI all,



I have an XML file that contain the following tags:



<A>

      <UserName>UserA</UserName>

      <Password>password</Password>

      <SID>rdf12</SID>

      <Host>10.8</Host>

</A>

<B>

      <UserName>UserB</UserName>

      <Password>password</Password>

      <SID>rdf12</SID>

      <Host>10.8.</Host>

</B>





I have a property file that has following properties:

userNameA   TestA

passwordA   passwordA

userNameB   TestB

and so on...





Now I need to update the XML file with the corresponding properties. After updation output should be something like



<A>

      <UserName>TestA</UserName>

      ......

</A>

<B>

      <UserName>TestB</UserName>

      ....

</B>



I cannot use replace <UserName>(.)*</UserName> because same tag is present in both A and B.



I know replaceregexp should serve the purpose but I am unable to do it due to multiple lines. I need to replace the complete set of A properties at one go...May be treating it as a single line.



How to do this?





Thanks in advance

Pankaj



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

RE: Replaceregexp in ANT

Posted by Martin Gainty <mg...@hotmail.com>.
Does Ant replaceregexp support Perl, regular or extended regular expressions?

Vielen Danke,
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Thu, 16 Apr 2009 13:28:10 +0200
> From: Martin.vGagern@gmx.net
> To: Pankaj_Arora01@infosys.com
> CC: dev@ant.apache.org
> Subject: Re: Replaceregexp in ANT
> 
> Pankaj Arora01 wrote:
> > I know replaceregexp should serve the purpose but I am unable to do
> > it due to multiple lines. I need to replace the complete set of A
> > properties at one go...May be treating it as a single line.
> 
> Haven't fully understood everything before, but a FileTokenizer, maybe
> together with the 's' flag to replaceregexp, should solve this.
> 
> http://ant.apache.org/manual/CoreTypes/filterchain.html#filetokenizer
> http://ant.apache.org/manual/OptionalTasks/replaceregexp.html
> 
> The user mailing list is probably a better place to ask such questions
> than this dev list. See http://ant.apache.org/mail.html
> 
> Greetings,
>  Martin von Gagern
> 

_________________________________________________________________
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009

Re: Replaceregexp in ANT

Posted by Martin von Gagern <Ma...@gmx.net>.
Pankaj Arora01 wrote:
> I know replaceregexp should serve the purpose but I am unable to do
> it due to multiple lines. I need to replace the complete set of A
> properties at one go...May be treating it as a single line.

Haven't fully understood everything before, but a FileTokenizer, maybe
together with the 's' flag to replaceregexp, should solve this.

http://ant.apache.org/manual/CoreTypes/filterchain.html#filetokenizer
http://ant.apache.org/manual/OptionalTasks/replaceregexp.html

The user mailing list is probably a better place to ask such questions
than this dev list. See http://ant.apache.org/mail.html

Greetings,
 Martin von Gagern