删除成对以外的引号

remove quotes that occur other than pairs

如何删除不成对出现的额外引号。 假设,

title:"no spacing before" and text breaks "
title:"no spacing before" and text breaks " after this

我需要输出如下:

title:"no spacing before" and text breaks
title:"no spacing before" and text breaks after this

您可以像这样使用正则表达式:

(".*?")|"

使用替换字符串:


Working demo

以下正则表达式适用于多对双引号 ("),并匹配对组。要删除不成对的双引号,请将匹配替换为 \1:

([^"]*(?:"[^"]+"[^"]*)+[^"]*)(["])?

演示是HERE