This seems to do what you need, but I am not sure it is really the best 
approach. It will probably be quite slow, and may allow hackers to break 
into your house and steal your children... Use at own risk!

function interpolate(str)
       str = string("\"", str, "\"")
       eval(parse(str))
end


julia> LBP=30 ; s="LBP = \$LBP" ; interpolate(s)
"LBP = 30"


Cheers,

Tom

On Sunday, 26 April 2015 09:11:27 UTC-4, will ship wrote:
>
> Hi Tamas I actually want to completely remove the "\" before the "$"  as I 
> want the following type of operation:
>
> julia> LBP=30
> 30
>
> julia> string ="LBP =$LBP"
> "LBP =30"
>
> Cheers 
> Will
>
> On Sunday, April 26, 2015 at 1:44:05 PM UTC+1, Tamas Papp wrote:
>>
>> Maybe something like 
>>
>> julia> s = "my \\ escaped \\\$ \$ string" 
>> "my \\ escaped \\\$ \$ string" 
>>
>> julia> replace(s, "\\\$", "\$") 
>> "my \\ escaped \$ \$ string" 
>>
>> Best, 
>>
>> Tamas 
>>
>> PS.: Incidentally, is there a way to enter strings with $ without 
>> escaping them? Ie something like a non-standard string literal that just 
>> ignores the $'s. 
>>
>> On Sun, Apr 26 2015, will ship <[email protected]> wrote: 
>>
>> > Hi 
>> > 
>> > I am reading in a text file with special characters e.g. : " Blah is 
>> $LBP" 
>> > when I read it in to a variable the "$" gets replaced with "\$". But I 
>> > actually want the $ non-escaped so that when handling the string 
>> variable 
>> > it prints the $LBP value. 
>> > 
>> > Is there anyway of doing this, our just to remove the "\" in the string 
>> > without removing the "$" as well? 
>> > 
>> > Thanks in advance. 
>> > 
>> > Will 
>>
>

Reply via email to