locked
How to deal with a double quote in a string RRS feed

  • Question

  • Hi I have the following string :

    <img src="http://localhost"/DotNetNuke/DNNuke/Portals/0/Me.jpg" originalAttribute="src" alt="" width="160" border="0" height="119" /><br /> 

    What I want to do is use vb.net code to get rid of that " marked in red.

    I have tried String.Replace("""/", "/")
    and  String.Replace("" & Chr(34) & "/", "/")

    as well as one horrible attempt using substrings.  It was ugly :)

    But so far nothing has worked.

    Some posts I have been reading have involved stuff with regular expressions but regular expressions make my head hurt so I would like to avoid them if possible.

    Any advise would be appreciate.

    Thanks!

    Thursday, September 25, 2008 9:20 PM

Answers

  • Hi,

    I would have expected your first attempt to work.  What did it do that was different from what you expected?

    I tried running the following code:

    Dim str As String = "<img src=""http://localhost""/DotNetNuke/DNNuke/Portals/0/Me.jpg"" originalAttribute=""src"" alt="""" width=""160"" border=""0"" height=""119"" /><br /> "

    Stop

    And then evaluated str.Replace("""/","/") in the watch window
    It came back as:
    "<img src="http://localhost/DotNetNuke/DNNuke/Portals/0/Me.jpg" originalAttribute="src" alt="" width="160" border="0" height="119" /><br /> "

    Am I misunderstanding the problem here?

    Wednesday, October 1, 2008 12:24 AM
    Moderator

All replies

  • Hi,

    I would have expected your first attempt to work.  What did it do that was different from what you expected?

    I tried running the following code:

    Dim str As String = "<img src=""http://localhost""/DotNetNuke/DNNuke/Portals/0/Me.jpg"" originalAttribute=""src"" alt="""" width=""160"" border=""0"" height=""119"" /><br /> "

    Stop

    And then evaluated str.Replace("""/","/") in the watch window
    It came back as:
    "<img src="http://localhost/DotNetNuke/DNNuke/Portals/0/Me.jpg" originalAttribute="src" alt="" width="160" border="0" height="119" /><br /> "

    Am I misunderstanding the problem here?

    Wednesday, October 1, 2008 12:24 AM
    Moderator
  • Yes He is right. In vb... to show a single "  you need to put two in its place.

    So if you want to show a string like mar"tin

    you'd write "mar""tin"


    Rahul Parashar http://www.rahulparashar.com
    Thursday, October 9, 2008 12:12 PM