'regex to replace regular quotes with curly quotes

I have a block of text where the opening and closing quotes are same

"Hey", How are you? "Hey there"... “Some more text” and some more "here".

Please note that the quote character is " and not “ ” these characters

(["'])(?:(?=(\\?))\2.)*?\1

I want to replace the opening " character as “

it will now look as “Hey", How are you? “Hey there"... “Some more text” and some more “here".

and then again running I can simply find and replace the left over " occurance as ”

and that would give the expected output which should look as

“Hey”, How are you? “Hey there”... “Some more text” and some more “here”.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source