7 Replies Latest reply on Jan 4, 2016 12:50 AM by Laubender

    Delete the first 4 characters in a cell... (IND CS4)

    Marcos Suárez

      I need to delete the first 4 characters when the text of the cells begins with "<Cs".


      Is it possible without using "Search/Replace"?

       

      My script is something like this... 


      var doc=app.documents[0]; 
      var allTablesArray=doc.stories.everyItem().tables.everyItem().getElements();
      
      
      /************************************************************************/
      var TbCount = allTablesArray.length;
      for(var Tb=0; Tb<TbCount; Tb++) {
        var Tab = allTablesArray[Tb];
        var numRows = Tab.rows.length - 1;
        for(var R=numRows; R>=0; R--) {
        var numCells = Tab.rows[R].cells.length - 1;
        for(var Td=numCells; Td>=0; Td--) {
        var xCell = Tab.rows[R].cells[Td];
        var Content_3 = xCell.contents.slice(0,3);
        if (Content_3 == "<Cs") {
        //Remove the first 4 characters in the cell
        }
        if (Content_3 == "<Rs") {
        //Remove the first 4 characters in the cell
        }
        }
        }
      }
      //*****************