A solution that will work in all browsers should not contain a backward preview block. In addition, to replace the quotes, which follow each other through one letter, you cannot do without a preview block ahead .
Therefore, the best solution will be
var text = 'Эту "задачу" "ну"ж"н"о сделать" регулярным"и выраже"ниями'; var pattern = /([а-яё])"(?=[а-яё])/ig; var result = text.replace(pattern, "$1'"); console.log(result);
See the regular expression demo .
Details
([а-яё]) - Exciting group number 1 (reference to the value of this group from the replacement pattern by using $1 ): the letter of the Russian alphabet" - double quote(?=[а-яё]) - a block of preview ahead, which checks the following condition: immediately after the sign " must be a letter of the Russian alphabetig - modifiersi - case insensitive enabledg - search for all occurrences enabled
For browsers and environments that support ECMAScript 2018, you can use the following solution for any language:
var pattern = /(?<=\p{L})"(?=\p{L})/gu; var result = 'Эту "задачу" "ну"ж"н"о сделать" регулярным"и выраже"ниями'.replace(pattern, "'"); console.log(result);
\p{L} finds any letter.