How to store string to a variable which contains both single & double quote? The string should be dynamic, not static.

For example : thisis'a"string
another string is : this'i"sastring
The quotes will be vary its position. Is it possible to store these type of string to a variable?
Thank you

Recommended Answers

All 8 Replies

Member Avatar for iamthwee

Yes you either escape it using a backward slash...

But is this a mysql query or something to be displayed in html? What's the background?

Thank you for replying.
This is not my sql query. The string is source code of a webpage.
Here is another example.
<a href="link1.html"><img src="im.jpg" title="that's what i am"></a>
In the code the both quotes appearing. There are multiple codes like this and i want to store each of this to a variable.

Member Avatar for diafol

if you're storing them in a variable, why do you need to mess with them?

Hi diafol, Did you see the example?

Member Avatar for diafol

Yes, but I don't see the problem. Are you scraping data from a webpage?

Yea, its from a webpage.
<a href="link1.html"><img src="im.jpg" title="that's what i am"></a>
How to store the above code to a variable?

Member Avatar for diafol

You seem reluctant to show any code that you're using. Show us your code so we hav a better idea of what you're trying to do.

How to store the above code to a variable?

If it's coming from a scrape, the text will already be in a variable, won't it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.