How to replace " with " character in String

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • DrBunchman
    replied
    Originally posted by jmash
    Suppose I have the following string whch is part of an xml string:
    String s= "Script Id="Test&q uot; "

    And I need to get
    s= "Script Id="Test" "

    Can anyone tell me how this can acheived?

    Thanks,
    jmash
    No problem JMash,

    To insert a double quotation inside a string you need to use two double double quotation marks next to each other. So you would replace all instances of &quot with "". Try this:

    s = s.Replace("&quo t", """")

    This little rule about quote marks applies to apostrophe's as well where they are used as string delimiters (for example in SQL) and is an important thing to be aware of.

    Give this a try and let me know if it helps,

    Dr B

    Leave a comment:


  • Shashi Sadasivan
    replied
    Have you tried the Replace?

    String s= "Script Id="Test&q uot; ";
    s = s.Replace("&quo t;", "\"");

    backslash is used as an escape character.
    Note the 3 quotation marks in the second argument of the Replace method

    Leave a comment:


  • jmash
    started a topic How to replace " with " character in String

    How to replace " with " character in String

    Suppose I have the following string whch is part of an xml string:
    String s= "Script Id="Test&q uot; "

    And I need to get
    s= "Script Id="Test" "

    Can anyone tell me how this can acheived?

    Thanks,
    jmash
Working...