Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put data containing double-quotes in string variable? [duplicate]

Tags:

vb.net

Possible Duplicate:
replace " in vb.net

How to put data containing double-quotes in string variable? Aug 01, 2003 02:30 AM | LINK

I need to store a string that contains words in double quotes. The complete string data is presented to the variable in double quotes, but the next double quotes within the data ends the string and the remaining text gives a syntax error. How can I place literal double-quotes in a string variable? For example:

Dim MyVar as string = "stm_bm(["menu53d0",400,"","blank2.gif",0,"","",0,0,250,0,1000,1,0,0,""],this);" 
like image 269
Manikandan Thangaraj Avatar asked Oct 14 '11 11:10

Manikandan Thangaraj


People also ask

How do you add double quotes to a string variable?

To place quotation marks in a string in your code In Visual Basic, insert two quotation marks in a row as an embedded quotation mark. In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark.

How do you cut a double quote into a string?

To remove double quotes just from the beginning and end of the String, we can use a more specific regular expression: String result = input. replaceAll("^\"|\"$", ""); After executing this example, occurrences of double quotes at the beginning or at end of the String will be replaced by empty strings.

How do you concatenate a double quote to a string variable in Java?

You can concatenate double quotes in java by using the addition + operator. This operator is used for performing addition of numbers and concatenation of strings.


1 Answers

You can escape (this is how this principle is called) the double quotes by prefixing them with another double quote. You can put them in a string as follows:

Dim MyVar as string = "some text ""hello"" hello" 

This will give the MyVar variable a value of some text "hello" hello.

like image 148
Sai Kalyan Kumar Akshinthala Avatar answered Oct 06 '22 12:10

Sai Kalyan Kumar Akshinthala