2 Replies Latest reply on Nov 27, 2008 7:43 PM by (charles_darwin)

    [CS2][JS]Find/Change/Expand Help....

    Level 1
      Please i really can't get this done or have no idea how to. There are people who helped me do this function but i don't know how to apply it in my actual file.

      app.findPreferences = app.changePreferences = null;
      app.findPreferences.appliedCharacterStyle = 'cbib';
      var myFound = app.activeDocument.search( '' );

      for (j=0; j > myFound.length; j++)
      var LamanNgCbib = myFound[j].contents.slice(1,-1);
      var dar = LamanNgCbib.replace(/\uFEFF/g, '');
      var expanded = unrange(dar);
      app.activeDocument.search( dar, false, false, expanded )

      function unrange (s)
      return s.replace (/(\d+)\u2013(\d+)/g, expand)

      function expand ()
      var expanded = [];
      var start = Number (arguments[1]);
      var stop = Number (arguments[2]);
      for (var i = start; i <= stop; i++)
      expanded.push (i);
      return expanded

      The script only replaces the first instance ([1,3,5-7] becomes [1,3,5,6,7,8]) but the rest does not. so i have to run the script again for the others to unrange and wait forever 'til the script finished. Is there anyway to loop my search and replace so i have to run the script only once? Please i really need your help scripters.