15 Replies Latest reply on Oct 28, 2014 2:04 PM by gharezlak

    find/replace multiple strings in PDF

    gharezlak

      Hi Developer Community,

       

      I'm pretty new to JavaScript and Acrobat, but I'm trying to help a coworker out. We're attempting to remove any pronouns that imply gender in candidate feedback (we're recruiters). I came up with the following script, but I'm getting a syntax error. I was curious if there's something unique about Adobe JS that I don't know, or if I just made a blunder with my brute force solution. Any help would be greatly appreciated. Thanks in advance!!

       

      function DeGenderfy(){

          var regex = new RegExp (/he | she | his | hers | him | her | himself | herself | he\'d | she\'d | he\'ll | she\'ll/gi);

      for(var pg=0;pg<this.numPages;pg++) {

          var len = getPageNumWords(pageNum);

          }

      // Loop over words on page

           for(var i=0;i<len;i++) {

               var wd = this.getPageNthWord(pageNum,i,false);

               var searchValue = rg.test(wd);

                  if( searchValue == "he") {

                       searchValue.replace("he","they");

                 }else if( searchValue == "she") {

                       searchValue.replace("she","they");

                  }else if( searchValue == "his") {

                       searchValue.replace("his","their");

                  }else if( searchValue == "hers") {

                       searchValue.replace("hers","their");

                  }else if( searchValue == "him") {

                       searchValue.replace("him","them");

                  }else if( searchValue == "himself") {

                       searchValue.replace("himself","themselves");

                  }else if( searchValue == "he'd") {

                       searchValue.replace("he'd","they'd");

                  }else if( searchValue == "she'd") {

                       searchValue.replace("she'd","they'd");

                  }else if( searchValue == "he'll") {

                       searchValue.replace("he'll","they'll");

                  }else if( searchValue == "she'll") {

                       searchValue.replace("she'll","they'll");

                  }else if( searchValue == "her") {

                       searchValue.replace("her","them");

                  }else if( searchValue == "herself") {

                       searchValue.replace("herself","themselves");

             }

           }

      }

       

       

      SyntaxError: syntax error

      1:Console:Exec

      undefined