4 Replies Latest reply on Feb 17, 2010 5:47 AM by ghavik

    script or GREP search line for missing quotation marks (opening or closing)

    ghavik Level 1

      Hi there,


      I've being trying to figure out a GREP search that will help me find quotations that haven't been opened or closed properly. Does anyone know if there exists a script that will mark/help me find the quotation marks that incorrectly stand alone? A GREP search line would be fine too.


      Following is an example - just to make sure I made myself clear:


      'why is the closing quotation mark missing after the question mark? I asked.

      'I don't know, this line seems to be fine, with opening and closing quotation mark,' I answered.

      Although this line is missing an opening quotation mark.'


      Hope somebody can help me, I'm pretty sure I'm not the first person searching for a solution on this issue - sorry, I'm not to bright with scripting or GREP.





        • 1. Re: script or GREP search line for missing quotation marks (opening or closing)
          [Jongware] Most Valuable Participant

          I don't think it's possible to catch *all* mishaps at once, but you can search for correct pairs of opening/closing quotes.

          This method temporarily changes the swatch color of your text, so don't do it if you might have colored text! In that case, use something else (another text attribute you don't use, such as Underline; or something semi-invisible, such as a text stroke color).


          1. Make a new color swatch and name it 'good_quotes'.

          2. Replace all occurrences of




          with just the text color 'good_quotes' in the Replace With field (be sure to empty the text box of the Replace With field!).

          In case you have difficulties seeing these, the first character is a double opening quote, then inside the "OR" group an open and a close set, then after that set another double closing quotes. Do not attempt to use the GREP shortcuts ~{ and ~} -- these are causing ID to crash at random Copy-and-paste them from your document.

          This GREP will search for a set of opens, then anything but open or close, followed by a close pair. Now all 'good' ones are marked with your color swatch.


          3. Search for opening quotes in your regular text color (usually, [Black]). These are missing a closing pair somewhere after that.

          4. Repeat for closing quotes.

          5. Delete the swatch 'good_quotes', replacing it with your text color, to restore the document to normal.

          1 person found this helpful
          • 2. Re: script or GREP search line for missing quotation marks (opening or closing)
            Shonkyin Level 3

            Hi Gijs,



            If you want trigger direct on missing closing quotes text then use below grep:






            below is for missing opening quotes






            Just two search in your document but remember it will work with Typographer's quotes only.



            Hope it will help you.





            2 people found this helpful
            • 3. Re: script or GREP search line for missing quotation marks (opening or closing)
              ghavik Level 1

              As you say, it's not waterproof, but it is really helpfull, thanks. The unclosed quotation are easy to find this way.


              In Dutch we mainly use single quotation marks (double quotation marks are only used for quotations within quotations). This brings an extra dimension to the issue, since the apostrophe and single quotation mark are the same character. So a phrase like ' I'm having problems finding unopened quotations' with your GREP suggestion will mark the apostrophe in I'm as the closing quotation mark.


              So what I'll do is:


              1. find unclosed quotations ‘[^’]+?‘ and mark them with a character style WARNING;


              2. GREP search ’[^‘]+?’ two following closing quotation marks and make them C=100;

              3. GREP search ’[^‘]+?’ the correct quotations and mark it all K=100;

              4. Do a regular search for '^$ any apostrophe/quotation mark followed by a letter and mark them all K=100;

              5. Do a regular search for any closing quotation mark left in C=100 and manually WARNING-mark the ones that need to be looked at by the editor.


              Step 4 is a bit tricky since any error like 'I agree,'he said (no space after quotation mark) will be marked back to K=100 as well, but those errors I'll probably notice since they're underlined by the grammar control option.


              Thanks again for the help.

              • 4. Re: script or GREP search line for missing quotation marks (opening or closing)
                ghavik Level 1

                Thanks so much, I used both your suggestion and the other post to create a solution.