4 Replies Latest reply on Oct 4, 2014 3:45 AM by Obi-wan Kenobi

    GREP trouble

    David André Erichsen

      Hi,

       

      I want to change lists that comes numbered like tils:

       

      1. some text

      2. some text

      3. some text

       

      to this

       

      1) some text

      2) some text

      3) some text

       

       

      This GREP work if i do a manual search in InDesign:   "(?<=^\d)\. |(?<=^\d\d)\."  ->  ") "

      But when i put it into this script (works with other search-criteria) nothing happens:

       

      Can someone please tell why this does'nt this work?

       

       

       

       

      if (parseFloat(app.version) < 6)

      doReplace();

      else

      app.doScript(doReplace, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Expand State Abbreviations");

       

       

      function doReplace ()

      {

      if (parseFloat(app.version) < 6)

      doReplace();

      else

      app.doScript(doReplace, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Expand State Abbreviations");

      function doReplace ()

      {

       

       

      try {

        RemoveExcessSpacing();

      } catch(err) {

              var msg = "Select textframe";

              alert(msg);

      }

      function RemoveExcessSpacing() {

        var story;

        var doc   = app.activeDocument;

        var sel   = doc.selection;

        var frame = sel[0];

        if (frame && frame.constructor.name === "TextFrame") {

        story = frame.parentStory;

        } else {

        throw "Ingen tekstblokk markert";

        }

      app.findGrepPreferences.findWhat = "(?<=^\d)\. |(?<=^\d\d)\. ";

      app.changeGrepPreferences.changeTo = ") ";

      story.changeGrep();

      }}}