3 Replies Latest reply on May 21, 2010 10:17 AM by Tom Tomasko

    Problem with GREP finding styles

    Tom Tomasko Level 1



      Below is a script that finds any one to three digit number and then further selects out only those numbers that are superscripted or use the Open Type superscripted font style.


      It works if I only look for either of these styles but not both at the same time. When I use the script as written below to find superscripted OR Open Type superscripted it finds all numbers. Why is that happening?


      Further, I built the script that filters out all numbers for these styles because I could not see how I could create a script that utilizes a GREP search itself for character styles.


      Any help would be appreciated.






      var myDoc = app.activeDocument;
      //array below is all one to three digit words.
      var endNotes = theGrepFinder(myDoc,"\\d{1,3}");
      // Below is a filter to get just those that are superscripted (1936749411) or use Open Type SuperScripted(1884247155).
      var arrFiltered = [];
      for(var a = 0; endNotes.length > a; a++){
              if(endNotes[a].position == 1936749411||1884247155){
                  }// end if
              }//end for
          endNotes = arrFiltered;


      function theGrepFinder(docRef,grepFindIt){
          app.findGrepPreferences = NothingEnum.NOTHING;
          app.changeGrepPreferences = NothingEnum.NOTHING;
          app.findGrepPreferences.findWhat = grepFindIt;
          var arrGrepFindIt = myDoc.findGrep();
          return arrGrepFindIt;
      }//end theGrepFinder