Reputation: 303
for example:
x = "This is my string(string) another string(string)";
what i want to do is to insert a single quote after (
and before )
each.
Upvotes: 0
Views: 43
Reputation: 815
Jack's answer is very short, which is good. If you're the kind of person who likes a process that easier to understand, but longer, here goes...
var myString = "This is my string(string) another string(string)";
myString = myString.split("(");
myString = myString.join("('");
myString = myString.split(")");
myString = myString.join("')");
console.log(myString);
Upvotes: 1
Reputation: 21183
Something like this:
var startStr = "This is my string(string) another string(string)";
var endStr = startStr.replace(/\(/g, '(\'').replace(/\)/g, '\'\)');
console.log(endStr); //This is my string('string') another string('string')
Upvotes: 2