4 Replies Latest reply on Aug 23, 2016 7:48 AM by Skemicle

    Match last line characters

    karthiks94217840 Level 2

      Dear Friends.

       

      I need your help:

       

      My Requirements: How to match 1st line last character, 2nd line last characters and 3rd line last characters?

       

      Example:

       

      Last 1st line character >> a

      Last 2nd line character >> a

      Last 3rd line character >> a

       

      My code below: (Not working)

       

      var myDocument = app.activeDocument;  
      //~ var myLine = app.selection[0].lines;
      var myLine = myDocument.stories.everyItem().paragraphs.everyItem().lines.everyItem().getElements();  
      for(i=0; i<myLine.length; i++)  
      {  
          var myChar;
          if (String(myLine[i].characters.lastItem().contents).match(/\s/)){
              myChar = myLine[i].characters.item(myLine[i].characters.length);
              alert("String matches");
              }
          else{
              myChar = myLine[i].characters.lastItem(); 
              }
              
          var myCharCon = myChar.contents;
         alert(myCharCon)
      
      
          if((String(myLine[2].characters.lastItem(-2)).charCodeAt (0).toString(16)).match(String(myLine[6].characters.lastItem(-2)).charCodeAt (0).toString(16))){
              alert("String matches");
              }
          }
      

       

       

      Please suggest friend

       

      Thanks in Advance

      KS