5 Replies Latest reply on Mar 31, 2011 5:32 PM by adobechr

    GREP FindChangebyList Error Help

    adobechr Level 1

      Hi,

       

      I have looked through similar posts about the errors...  but I haven't been able to make it work (it works inside InDesign Find/Change fine). I have double-backslashed (as mentioned in other posts), but to know avail. Can you one of you guru's look at this and let me know how to make it work in FindChangebyList?

       

      grep {find what:"(\d|\d+.?\d+?)(?:g fiber/)"} {change to:"$1|"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Strip just the number i.e. 2.78g fiber

       

      Here is some sample raw copy that I am trying to change with script above:

       

       

      (404 cal/22.01g fat/3.6g fiber/13.7g carbs/33.35g protein/1292.5mg sodium)

      (20 cal/g fat/5g carbs/2mg sodium)

       

       

      Thanks!

        • 1. Re: GREP FindChangebyList Error Help
          Reese 0o0o

          You just need an extra \ before every any digit code.

           

          You had:

          "(\d|\d+.?\d+?)(?:g fiber/)"

           

          You need:

          "(\\d|\\d+.?\\d+?)(?:g fiber/)"

           

          I tested it with your sample and it worked.

           

          Hope that helps.

          • 2. Re: GREP FindChangebyList Error Help
            adobechr Level 1

            Darn, still get that Java 25 error.

             

            I changed the file to this:

             

            grep {find what:"(\\d|\\d+.?\\d+?)(?:g fiber/)"} {change to:"$1|"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Strip just the number i.e. 2.78g fiber

             

            Used text editor and saved as a UTF-8 and as well as Wester (Mac OS Roman)...   I read somewhere this script only like certain kind of formats. I am stumped.

             

            Any other ideas? Thanks!

            • 3. Re: GREP FindChangebyList Error Help
              Reese 0o0o Level 1

              Here is the code I used stripped to its basic elements. With a new document with 1 text box and your sample text. Perhaps the error is somewhere besides the grep syntax, because that seems to work fine.

               

               

               

              var myDocument = app.activeDocument;

               

              var myTextFrame1 = myDocument.textFrames.item(0);

               

              app.findGrepPreferences = app.changeGrepPreferences = null;

               

              //app.findGrepPreferences.findWhat = "(\d|\d+.?\d+?)(?:g fiber/)";

              app.findGrepPreferences.findWhat = "(\\d|\\d+.?\\d+?)(?:g fiber/)";

               

              //app.changeGrepPreferences.changeTo = "$1|";

              app.changeGrepPreferences.changeTo = "$1|";

              myTextFrame1.changeGrep();

               

              app.findGrepPreferences = app.changeGrepPreferences = null;

              • 4. Re: GREP FindChangebyList Error Help
                [Jongware] Most Valuable Participant

                Does this script still desperately need its {items} separated by Tabs?

                • 5. Re: GREP FindChangebyList Error Help
                  adobechr Level 1

                  Started over by using a script that I knew and copying in the new grep info. It worked...   it must have been tabs (although I checked that). Thanks guys...  the double backslash was the first problem -- tabs second.

                   

                  Thanks.