I think the replies here may have missed your statement that you are
"reading a text file" not "writing these strings in you code" (or perhaps I
misread something).

When Julia displays a string in the REPL, it adds escape characters and
quotes so that you can copy it back into other Julia context and get back
the same string. But these characters are not actually part of the string,
any more than the " that is used to indicate that the type of the object is
a string:

julia> x="asdf\$LPB"
"asdf\$LPB"

julia> display(x)
"asdf\$LPB"

julia> println(x)
asdf$LPB



On Sun, Apr 26, 2015 at 9:11 AM will ship <[email protected]> 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