3 Replies Latest reply on May 26, 2016 12:25 PM by pixxxel schubser

    GREP help

    Rondo6666

      I've got a (hopefully) simple grep query.

       

      I'm attempting to create a script that will clean up a database before merging into a variable data document. All the problematic data is consistent, I just don't know how to write the text file so scripteditor will buy in. I'm editing the text file being referenced by the indesign script "FindChangeByList.applescript".

       

      Here's the mission:

       

      I need to replace the following text:

      Screen Shot 2016-05-26 at 10.18.16 AM.png

       

      with - Three Year Olds .......... 118 lbs."," Older .......... 124 lbs.

       

      Simple - right?

       

      Any help will be huge.

        • 1. Re: GREP help
          pixxxel schubser Level 5

          To little informations!

           

          But this grep does what you described:

          search:

          (?<=\r)(Three Year Olds)\r(\d+)\r”,”\r(Older)\r(\d+)

          replace with:

          $1 .......... $2 lbs.”,” $3 .......... $4 lbs.

          • 2. Re: GREP help
            Rondo6666 Level 1

            Seems to have been just enough information!!

             

            I think we're really close.

             

            I'm using this syntax:

            grep{find what:"(?<=\r)(Three Year Olds)\r(\d+)\r","\r(Older)\r(\d+)"}{change to:"$1 .......... $2 lbs.$3 .......... $4 lbs."}{include footnotes:true, include

            But applescript is apparently getting confused by the "," text. Can it be protected somehow?

             

            set properties of find grep preferences to {find what:\"(?<=\\r)(Three Year Olds)\\r(\\d+)\\r\",\"\\r(Older)\\r(\\d+)\"}

            set properties of change grep preferences to {change to:\"$1 .......... $2 lbs.$3 .......... $4 lbs.\"}

            \

            (Note the ",\")

            • 3. Re: GREP help
              pixxxel schubser Level 5

              I'm not familiar with AppleScript.

               

              Does this Javascript works for you (standalone) ?

              Try it on a copy of your document.

              app.findGrepPreferences = null;
              app.changeGrepPreferences = null;
              app.findGrepPreferences.findWhat = '(?<=\\r)(Three Year Olds)\\r(\\d+)\\r(\”,\”)\\r(Older)\\r(\\d+)';
              app.changeGrepPreferences.changeTo = '$1 .......... $2 lbs.$3 $4 .......... $5 lbs.';
              app.activeDocument.changeGrep();