How do I escape the " in the replace command?

View: New views
10 Messages — Rating Filter:   Alert me  

Parent Message unknown How do I escape the " in the replace command?

by Simon Jeffrey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am new to ant and I am trying to use the replace command to replace a
string that contains the " character.

Thanks

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


Re: How do I escape the " in the replace command?

by Gilbert Rebhan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simon Jeffrey schrieb:
> I am new to ant and I am trying to use the replace command to replace a
> string that contains the " character.

you have to provide more details =

What did you try already ?
Have you tried with regexp ?
Where comes that string from, is it part of a file ?
How does the file look like ?
...

btw. in regular expressions the quote or double quote
characters are not special, no metacharacters like f.e.
[ \ ^ $ . | ? .... etc.
so you don't need to escape them

Regards, Gilbert




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


RE: How do I escape the " in the replace command?

by Simon Jeffrey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to execute the command below as part of our weblogic
install.

Yes the string is part of a file.

I have tried using "e;, \", and \Q \E, but none of these options has
worked.

I was not aware of the regexp option.

Thanks, Jeff


<replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
  token="JAVA_OPTIONS=\"${JAVA_OPTIONS}\""
  value="JAVA_OPTIONS=\"${JAVA_OPTIONS}
-Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}\""/>


-----Original Message-----
From: Gilbert Rebhan [mailto:ant@...]
Sent: Tuesday, June 24, 2008 1:50 PM
To: Ant Users List
Subject: Re: How do I escape the " in the replace command?

Simon Jeffrey schrieb:
> I am new to ant and I am trying to use the replace command to replace
> a string that contains the " character.

you have to provide more details =

What did you try already ?
Have you tried with regexp ?
Where comes that string from, is it part of a file ?
How does the file look like ?
...

btw. in regular expressions the quote or double quote characters are not
special, no metacharacters like f.e.
[ \ ^ $ . | ? .... etc.
so you don't need to escape them

Regards, Gilbert




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


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


Re: How do I escape the " in the replace command?

by Gilbert Rebhan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simon Jeffrey schrieb:
> I am trying to execute the command below as part of our weblogic
> install.
>
> Yes the string is part of a file.
>
> I have tried using "e;, \", and \Q \E, but none of these options has
> worked.
>
> I was not aware of the regexp option.

untested, try with =

    <replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
   token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
   value='JAVA_OPTIONS="${JAVA_OPTIONS}"
-Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>

if that doesn't work, i would go with regexp

Regards, Gilbert



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


RE: How do I escape the " in the replace command?

by Rick Genter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> From: Gilbert Rebhan [mailto:ant@...]
> Sent: Tuesday, June 24, 2008 1:15 PM
> To: Ant Users List
> Subject: Re: How do I escape the " in the replace command?
>
> Simon Jeffrey schrieb:
> > I am trying to execute the command below as part of our weblogic
> > install.
> >
> > Yes the string is part of a file.
> >
> > I have tried using "e;, \", and \Q \E, but none of
> these options has
> > worked.
> >
> > I was not aware of the regexp option.
>
> untested, try with =
>
>     <replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
>    token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
>    value='JAVA_OPTIONS="${JAVA_OPTIONS}"
> -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>
>
> if that doesn't work, i would go with regexp

The HTML entity for " is ", not "e;
(http://www.w3.org/TR/html401/sgml/entities.html#h-24.4.1). Did the OP
have a typo in his e-mail, or did he try the wrong entity?
--
Rick Genter
Principal Software Engineer
Silverlink Communications

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


Re: How do I escape the " in the replace command?

by Gilbert Rebhan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gilbert Rebhan schrieb:

> Simon Jeffrey schrieb:
>> I am trying to execute the command below as part of our weblogic
>> install.
>>
>> Yes the string is part of a file.
>>
>> I have tried using "e;, \", and \Q \E, but none of these options has
>> worked.
>>
>> I was not aware of the regexp option.
>
> untested, try with =
>
>    <replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
>   token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
>   value='JAVA_OPTIONS="${JAVA_OPTIONS}"
> -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>
>

btw. after a second look, regardless whether a solution with
regexp would be more suitable =

i don't understand your try to mask ${JAVA_OPTIONS} with \" ... \"
if you simply write ${...} it will be replaced with the contents/the
value of the property at runtime

Regards, Gilbert

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


RE: How do I escape the " in the replace command?

by Simon Jeffrey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 ${JAVA_OPTIONS} appears in this file many times.  I only want this
specific instance (JAVA_OPTIONS="${JAVA_OPTIONS}") to be replaced, not
the others.

Thanks, Jeff

-----Original Message-----
From: Gilbert Rebhan [mailto:ant@...]
Sent: Tuesday, June 24, 2008 2:28 PM
To: Ant Users List
Subject: Re: How do I escape the " in the replace command?

Gilbert Rebhan schrieb:

> Simon Jeffrey schrieb:
>> I am trying to execute the command below as part of our weblogic
>> install.
>>
>> Yes the string is part of a file.
>>
>> I have tried using "e;, \", and \Q \E, but none of these options
>> has worked.
>>
>> I was not aware of the regexp option.
>
> untested, try with =
>
>    <replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
>   token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
>   value='JAVA_OPTIONS="${JAVA_OPTIONS}"
> -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>
>

btw. after a second look, regardless whether a solution with regexp
would be more suitable =

i don't understand your try to mask ${JAVA_OPTIONS} with \" ... \"
if you simply write ${...} it will be replaced with the contents/the
value of the property at runtime

Regards, Gilbert

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


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


Re: How do I escape the " in the replace command?

by Gilbert Rebhan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rick Genter schrieb:
> The HTML entity for " is ", not "e;
> (http://www.w3.org/TR/html401/sgml/entities.html#h-24.4.1). Did the OP
> have a typo in his e-mail, or did he try the wrong entity?

don't know if he had a typo in it, but you're right,
of course it should be " instead of "e;

but i think =

<replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
  token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
  value='JAVA_OPTIONS="${JAVA_OPTIONS}"
  -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>

is equivalent to

<replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
  token="JAVA_OPTIONS="${JAVA_OPTIONS}""
  value="JAVA_OPTIONS="${JAVA_OPTIONS}"
  -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}"/>

when the later is the 'cleaner' version, but also more
chars to write ;-)


Regars, Gilbert



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


RE: How do I escape the " in the replace command?

by Simon Jeffrey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This version below works :) !!! Very good to know, and really the
easiest, most straight-forward way to handle double qoutes in your
source and target strings.

<replace file="testfile.txt"
          token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
          value='JAVA_OPTIONS="${JAVA_OPTIONS}
-Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}"'/>

"The HTML entity for " is ", not "e;
(http://www.w3.org/TR/html401/sgml/entities.html#h-24.4.1). Did the OP
have a typo in his e-mail, or did he try the wrong entity?"

It was not a type-o in the email...I had it wrong.

Thanks everyone VERY MUCH!!!  Now hopefully it will work on unix as well
(I've only tested on windows so far.)


Thanks, Jeff

-----Original Message-----
From: Rick Genter [mailto:rgenter@...]
Sent: Tuesday, June 24, 2008 2:27 PM
To: Ant Users List
Subject: RE: How do I escape the " in the replace command?

> From: Gilbert Rebhan [mailto:ant@...]
> Sent: Tuesday, June 24, 2008 1:15 PM
> To: Ant Users List
> Subject: Re: How do I escape the " in the replace command?
>
> Simon Jeffrey schrieb:
> > I am trying to execute the command below as part of our weblogic
> > install.
> >
> > Yes the string is part of a file.
> >
> > I have tried using "e;, \", and \Q \E, but none of
> these options has
> > worked.
> >
> > I was not aware of the regexp option.
>
> untested, try with =
>
>     <replace file="${env.DOMAINDIR}/bin/setDomainEnv.${fileext}"
>    token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
>    value='JAVA_OPTIONS="${JAVA_OPTIONS}"
> -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}'/>
>
> if that doesn't work, i would go with regexp

The HTML entity for " is ", not "e;
(http://www.w3.org/TR/html401/sgml/entities.html#h-24.4.1). Did the OP
have a typo in his e-mail, or did he try the wrong entity?
--
Rick Genter
Principal Software Engineer
Silverlink Communications

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


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


Re: How do I escape the " in the replace command?

by Gilbert Rebhan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simon Jeffrey schrieb:
> This version below works :) !!! Very good to know, and really the
> easiest, most straight-forward way to handle double qoutes in your
> source and target strings.
>
> <replace file="testfile.txt"
>  token='JAVA_OPTIONS="${JAVA_OPTIONS}"'
>  value='JAVA_OPTIONS="${JAVA_OPTIONS}
> -Dweblogic.ProductionModeEnabled=${WEBLOGIC_PRODUCTION_MODE}"'/>


> Thanks everyone VERY MUCH!!!  Now hopefully it will work on unix as well
> (I've only tested on windows so far.)

works here on linux with ant 1.7.0/jdk 6, @work those '"'
stuff runs on AIX, should work on your unix box also
"write once run (debug) anywhere" ;-)

Regards, Gilbert

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

LightInTheBox - Buy quality products at wholesale price