The following code replace straight double quotes with curly double quotes:
const input = `"Line 1"
"Line 2
"Line 3"
Line 4`
const output = input.replace(/\"(.*?)(\")/g, '“$1”')
console.log(output)
There's a problem, though. Sometimes a line doesn't have a closing double quote (which indicates that the quotes continues on the line below). So the opening double quote won't be replaced:
`“Line 1$1”
"Line 2
“Line 3$1”
Line 4`
How to modify the regex so it also replaces opening double quotes that aren't followed by a closing double quote?
Desired output:
`“Line 1$1”
“Line 2
“Line 3$1”
Line 4`