3 Replies Latest reply on May 21, 2014 1:03 AM by BEGINNER_X

    Find tab Character

    BEGINNER_X Level 3

      Hi All,

       

      I need to find the tab character in the particular paragraph style "TX".

       

      1. Find the first tab character

       

      2. give shift return before the first tab character

       

      Please refer the screenshot:

      aaa.png

        • 1. Re: Find tab Character
          csm_phil Level 4

          Hi Beginner_X,

           

          Try the below JS code.

           

          app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item("TX");
          app.findGrepPreferences.findWhat="^.+$";
          var myText = app.findGrep();
          for(var i=myText.length-1; i>=0; i--){
              var mySelection = myText[i].paragraphs[0];
              var myRpl = mySelection.contents.replace("\t", "\n");
              mySelection.contents = myRpl;
              }
          

           

           

          thx,

          csm_phil

          • 2. Re: Re: Find tab Character
            csm_phil Level 4

            Hi Beginner_X,

             

            change this line only.

             

            var myRpl = mySelection.contents.replace("\t", "\n\t");
            

             

            thx,

            csm_phil

            • 3. Re: Re: Re: Find tab Character
              BEGINNER_X Level 3

              Hi Csm_Phil,

               

              Thank you for your quick response...

               

              I got the output in different way..

               

              app.findGrepPreferences = app.changeGrepPreferences = null;
              
              app.findGrepPreferences.appliedParagraphStyle = "TX";
              
              var myFnd = app.activeDocument.findGrep(true);
              
              for(i=0; i<myFnd.length; i++)
              {
                 
                  var myFound = myFnd[i].select();
                 
                  if(app.selection[0].lines.length > 1)
                  {
                      alert("selection line greater than 1")
                     
                      app.findGrepPreferences = app.changeGrepPreferences = null;
              
                      app.findGrepPreferences.findWhat = "(^.+?)(\\t)";
                     
                      app.changeGrepPreferences.changeTo = "$1\\n$2";
                     
                      app.selection[0].changeGrep();
                     
                      }
                
                  }
              
              

               

              csm: I want to give correct answers for you. But I not able find that option in this post.

              Anyone please help me to give correct answer for this request.