470,594 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

How to replace " with " character in String

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

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

Can anyone tell me how this can acheived?

Thanks,
jmash
Feb 13 '08 #1
2 34042
Shashi Sadasivan
1,435 Expert 1GB
Have you tried the Replace?

String s= "Script Id="Test" ";
s = s.Replace(""", "\"");

backslash is used as an escape character.
Note the 3 quotation marks in the second argument of the Replace method
Feb 13 '08 #2
DrBunchman
979 Expert 512MB
Suppose I have the following string whch is part of an xml string:
String s= "Script Id="Test" "

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("&quot", """")

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
Feb 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by ajikoe | last post: by
4 posts views Thread by barney | last post: by
1 post views Thread by Neil Zanella | last post: by
2 posts views Thread by Dmitriy Kolesnik | last post: by
5 posts views Thread by martin | last post: by
11 posts views Thread by BenI | last post: by
14 posts views Thread by Arne | last post: by
3 posts views Thread by Hvid Hat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.