3 Replies Latest reply on Sep 23, 2016 3:20 AM by jakec88782761

    counting changes in a find change grep

    jakec88782761 Level 2

      I've got a script which performs multiple find change greps and alerts how many of each grep search were made.


      This is the code:


      function seeSection () { 


         app.findGrepPreferences.findWhat= "the (section\\s+?\\d+?[\\.\\d+]?)"; 

          var changed = app.changeGrepPreferences.changeTo="$1";

          changed.appliedCharacterStyle="cross reference";

          var changes1 = app.activeDocument.changeGrep();

          if (changes1.length=1){

      alert(changes1.length+" instance of 'the section' was changed to 'section'.");


         alert(changes1.length+" instances of 'the section' were changed to 'section'.");




      No matter how many changes I know it has made it returns 1.


      It also does not apply the character style to the whole reference. The character style is supposed to underline the word section \d.


      It only underlines half of the word section:


      section 5


      Not sure what is happening.