If I understand well, lines like:
“ Criteria 1, ending with RD and beginning with LD, but not LDLD, remove RD ” “ “ Criteria 1, ending with RD but beginning with LDLD, do nothing to RD ” “ “ Criteria 2, beginning with LDLD, make it begin with LD ” Criteria 3 with non-matching RD, remove RD ”
To become:
“ Criteria 1, ending with RD and beginning with LD, but not LDLD, remove RD “ Criteria 1, ending with RD but beginning with LDLD, do nothing to RD ” “ Criteria 2, beginning with LDLD, make it begin with LD ” Criteria 3 with non-matching RD, remove RD
You can use regex:
^(?:("(?! ").*?)\s*"|(") "(.*)|((?!").*?)\s*")$
And replace with $1$2$3$4 .
See how it works here .
Or, if you meant characters, you can find something else similar here .
" Criteria 1, ending with RD and beginning with LD, but not LDLD, remove RD " " " Criteria 1, ending with RD but beginning with LDLD, do nothing to RD " " " Criteria 2, beginning with LDLD, make it begin with LD " Criteria 3 with non-matching RD, remove RD "
Become:
" Criteria 1, ending with RD and beginning with LD, but not LDLD, remove RD " Criteria 1, ending with RD but beginning with LDLD, do nothing to RD " " Criteria 2, beginning with LDLD, make it begin with LD " Criteria 3 with non-matching RD, remove RD
And if you need a debuggex image that can make the regex more understandable:
