3 Replies Latest reply on Jul 4, 2008 4:46 AM by Peter Kahrel

    Find/Change script help CS3 InDesign


      I have just upgraded to CS3 on my mac, I have no clue about GREP and scripting, have tried to understand it but am not really getting anywhere.

      I typeset books and we use dollar signs between the word/words we should italicise. ie:

      I've just read in the book, $As Time Goes By$,

      I know there must be a way of making a find/change to find the dollar signs and italicise everything between them.

      If dollar signs are a bad thing to use, I'm happy to change the marker to something else, not quote marks though.

      Can anybody please help. This would obviously speed up my work considerably.

      Thank You
        • 1. Re: Find/Change script help CS3 InDesign
          Peter Kahrel Adobe Community Professional & MVP
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = '\\$.+?\\$';
          app.changeGrepPreferences.fontStyle = 'Italic';

          All those backslashes are needed because $ has a special meaning in GREP, and if you use something else for delimiters the GREP expression looks a bit more relaxed. For example, with £, the expression would be £.+?£

          • 2. Re: Find/Change script help CS3 InDesign
            [Jongware] Most Valuable Participant
            A few follow-up on Peter's (as I'm experimenting with these):

            >app.findGrepPreferences.findWhat = '\\$.+?\\$';

            More complicated, but slightly better would be


            (you can replace the "\\$" with your markers as well), because this will only change the text
            i inbetween
            your markers to italic, which is often a requirement if the markers should remain in the text.

            Even better is this:

            >app.findGrepPreferences.findWhat = '\\$(.+?)\\$';

            >app.changeGrepPreferences.changeTo = '$1';

            (in addition to the Italics changeGrep line). This will apply the italics
            i and
            remove the '$' markers in one swoop.
            • 3. Re: Find/Change script help CS3 InDesign
              Peter Kahrel Adobe Community Professional & MVP
              >Even better is this:
              > app.findGrepPreferences.findWhat = '\\$(.+?)\\$';
              > app.changeGrepPreferences.changeTo = '$1';

              And so it is indeed. Another thought is that .+ doesn't get past the paragraph break. If you have a paragraph break between $s, you should tell InDesign to consider each story as a single paragraph/line by using the (?s) modifier:
              >app.findGrepPreferences.findWhat = '(?s)\\$(.+?)\\$';

              Or use a different construction, which doesn't care about paragraph breaks:

              >app.findGrepPreferences.findWhat = '\\$([^$]+)\\$';