10 Replies Latest reply on Jul 26, 2013 12:08 PM by RobertKyle

    grep search result + 1 HELP PLEASE!

    schiuma24 Level 1

      ok ppl, i have the following problem, i have a lot of dates to manage and sometimes i have to change all of them, for example, 1 day ahead of what i have, so (DD.MM.YYYY) 02.08.2013 has to become 03.08.2013

       

      i came up with this

       

      var myDocument = app.documents.item(0);

      //grep search string for the first two digits of this date format: DD.MM.201X

      var myString = "\\d\\d(?=\\.\\d+\\.201\\d)";

      //empties the search strings

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      //does not perform a search on the following items

      app.findChangeGrepOptions.includeFootnotes = false;

      app.findChangeGrepOptions.includeHiddenLayers = false;

      app.findChangeGrepOptions.includeLockedLayersForFind = false;

      app.findChangeGrepOptions.includeLockedStoriesForFind = false;

      app.findChangeGrepOptions.includeMasterPages = false;

      //searches for the grep string

      app.findGrepPreferences.findWhat = myString;

      //suposedly adds 1 to the result of the grep search

      var add = myDocument.findGrep() + 1;

      app.changeGrepPreferences.changeTo = add;

      myDocument.changeGrep();

      //empties searches again

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

       

      the problem is that it doesnt parse what it finds as integers but as [OBJECT]

       

      so what i get in return is [OBJECT]1.08.2013 instead of adding 1 to the first two digits