11 Replies Latest reply on Feb 24, 2012 9:45 PM by Tom Tomasko

    [CS3 JS] How to search for accented letters with GREP

    Tom Tomasko Level 1



      In the following script I have two words, each that has an accented letter. It appears that neither in the script nor in the Find and Replace dialog that GREP will recognize words with accents. It will replace accented characters however. I can do a search for words with no accents but that will lead to trouble when I only want to change the word if it has an accent.


      Any advice would be great!




      var myDoc = app.activeDocument;

      var rawWordsAccented = ["André","Barrës"]; //find these words

      var rawWordsAccentedDHyphens = ["~-Andr\\x{00E9}","~-Barr\\x{00EB}s"]; //replacement words

      for(var k =0; rawWordsAccented.length > k; k++){

          var numWords = theGrepChanger(myDoc,rawWordsAccented[k],rawWordsAccentedDHyphens[k]);   

          }//end for k


      function theGrepChanger(docRef,grepFindIt,grepChangeIt){

          app.findGrepPreferences = NothingEnum.NOTHING;

          app.changeGrepPreferences = NothingEnum.NOTHING;

          app.findGrepPreferences.findWhat = grepFindIt;

          app.changeGrepPreferences.changeTo = grepChangeIt;

          var arrGrepFindIt = myDoc.changeGrep();

          return arrGrepFindIt;

      }//end theGrepFinder