Re: Escaping Quotes [message #44515] |
Tue, 21 June 2005 14:39 |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Michael Wallace wrote:
> ...I *knew* there was a simple way to
> escape a quote... just escape it with another quote...
Yeah, I *knew* that too. At least I used to know it, a long time ago in
a galaxy far, far away.
It's copied from Fortran, isn't it?
--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|
Re: Escaping Quotes [message #44529 is a reply to message #44515] |
Tue, 21 June 2005 10:54  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> What about escape with quote ??
>
> print, '"This string doesn''t work ??"'
>
That was what I was forgetting. I *knew* there was a simple way to
escape a quote... just escape it with another quote. Thanks.
-Mike
|
|
|
Re: Escaping Quotes [message #44534 is a reply to message #44529] |
Mon, 20 June 2005 23:53  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
Michael Wallace wrote:
> I am having a brain cramp right now and can't even remember the simplest
> of IDL. How do you escape quotes given that you want both single and
> double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.
>
> -Mike
What about escape with quote ??
print, '"This string doesn''t work ??"'
bye ;)
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
|
|
|
Re: Escaping Quotes [message #44537 is a reply to message #44534] |
Mon, 20 June 2005 17:35  |
Peter Mason
Messages: 145 Registered: June 1996
|
Senior Member |
|
|
Michael Wallace wrote:
> I am having a brain cramp right now and can't even remember the
> simplest of IDL. How do you escape quotes given that you want both
> single and double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.
Although I feel safer with Mark's approach myself, there's also:
s = "What's ""leveraged""?"
and
s = 'What''s "leveraged"?'
(I hope you're viewing this with a fixed-space font.)
|
|
|
Re: Escaping Quotes [message #44538 is a reply to message #44537] |
Mon, 20 June 2005 16:55  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Michael Wallace wrote:
> I am having a brain cramp right now and can't even remember the simplest
> of IDL. How do you escape quotes given that you want both single and
> double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.
Doubtless there are many different ways to do it, using formatted
strings or byte<->string conversion or what-have-you, but the way that
seems simplest to my limited brain is to break the problem down into
substrings then recombine them:
IDL> print, '"This string mightn'+"'"+'t work, but it does!"'
"This string mightn't work, but it does!"
Ugly, though.
--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|