elvinguitar elvinguitar - 1 year ago 82
Vb.net Question

Removing the double quotes from a string

I have a variable

that is a String. The value of the
are in this format:
"['C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB01.JPG';'C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB02.JPG']"

How can I convert the value of the
to something without the double quotes in the beginning and ending (or should I change the String into some other types of variables? The format that I want is this:

['C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB01.JPG';'C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB02.JPG']

No double quotes


Answer Source

Try this...

Dim s as String = "['C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB01.JPG';'C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB02.JPG']"
s = s.Replace("'", "").Trim()

Any character or word or phrase or even a sentence is considered a string when it's enclosed in double quotes, but if the value of your string literally has double quotes, like this "SAMPLE", and you want to remove the double quotes, then do something...

Dim s as String = ""['C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB01.JPG';'C:\Users\Elvin Gentiles\Desktop\RiceLAB\BLB02.JPG']""
s = s.Replace("""", "").Trim()

Yes I noticed...double double quotes...I equated s to something that you say is passed from MATLAB, the string literally has double quotes, so to remove this, you replace double double quotes with nothing. That's how you do it in .NET. Your compiler interprets double double quotes as just a single quote :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download