I have a webpage where I want to replace all standard quote characters \" with the nicer looking quotes. For example, we have
\"hello world\"<
In case you have a string like test "abc" test "abc", you can check for each " whether it should be an opening or closing one by looking at how many " are preceeding it:
If it's an even amount it should be “, otherwise ”.
var str = 'test "abc" test "abc"';
var splitted = str.split('"');
var result = '';
for(var i = 0; i < splitted.length; i++) {
result += splitted[i] + ( i % 2 == 0 ? '&ldqou;' : '”' );
}
result = result.substring(0, result.length - 7); // remove last appended “