Hello forums !!
case:
Suppose i had the following var
var text = "This is my text with 'quotes'";
I want to replace the ' -> \' using some function like replace()
How to perform this ?
Thanks in advance to all of you
How to perform this ??
Moderator: General Moderators
Considering this is in the client side forum and the code looks like JS, I'd guess JavaScriptpatrikG wrote:Do you want to do this in Javascript or PHP?
I'm not very familiar with JS, but doesn't this work?
Code: Select all
var text = "This is my text with 'quotes'";
text.replace("'", "\'");- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Thanks Forums
I got the solution which is as:
Thanks for the help.
I got the solution which is as:
Code: Select all
var text = "This is my text with 'quotes'";
text = text.replace(/\'/g, "\\\'");