Reputation: 31
Remove double quotes inside double quotes of string using javascript.
I am receiving the string from the CSV file with double quotes inside double-quotes.
Actual input String is "my testing is "Done"";
After reading CSV file, I am getting the below string,
var test = "my testing is ""Done""";
I would like to get the output: my testing is "Done"
using javascript.
Expected Output: my testing is "Done"
Actual output: Main end Bus support location is \""A""
Upvotes: 0
Views: 151
Reputation: 35261
You could replace all the ""
with a single "
var test = 'my testing is ""Done""',
output = test.replace(/"+/g, '"');
console.log(output)
Upvotes: 3
Reputation: 389
<html>
<body onload="call()">
</body>
<script>
function call(){
var ss = 'my testing is ""Done""';
ss = ss.replace('""Done""',"\"Done\"");
}
</script>
</html>
Upvotes: 0