Search code examples
regexquotesdouble-quotes

remove quotes that occur other than pairs


How to remove extra quotes which do not occur in pair. Suppose,

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

I need to the output as follows:

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

Solution

  • You can use a regex like this:

    (".*?")|"
    

    With a replacement string:

    \1
    

    Working demo

    enter image description here