2 Replies Latest reply on Aug 12, 2013 5:29 AM by BEGINNER_X

    Find and Replace

    BEGINNER_X Level 3

      Hi All,

       

      Very very simple request for you...

       

      But I am strugling:

       

       

       

      //Need output from the below coding
      
      var myDoc = app.activeDocument;
      var myPstyles = myDoc.allParagraphStyles;
      var myAllPStyles = new Array();
      
      for(i=2; i<myPstyles.length; i++)
      {
        var myParaName = myPstyles[i].name;
        myAllPStyles.push(myParaName)
        myAllPStyles.replace(/\,/, "\r")               //Please help in this line
        alert(myAllPStyles)
        }
      ________________________________________________________________________________
      
      //Using this code I got output
      //var myParaStyles = myDoc.paragraphStyles.everyItem().name.join("\r");
       //alert(myParaStyles)
      

       

       

      Output I needed as per below screenshot:

       

      One by one.png

       

      Thanks in advance

      Beginner

        • 1. Re: Find and Replace
          Mac_rk Level 2

          try this

           

          var myDoc = app.activeDocument;

          var myPstyles = myDoc.allParagraphStyles;

          var myAllPStyles = new Array();

           

          for(i=1; i<myPstyles.length; i++)

          {

            var myParaName = myPstyles[i].name;

            myAllPStyles.push(myParaName)

          var temp = myAllPStyles.toString().split(",")

           

            }

          alert(temp.toString().replace (/\,/gi, "\r"))

          • 2. Re: Find and Replace
            BEGINNER_X Level 3

            Hi Mac,

             

            Thank for your valuable reply...

             

            I have small clarification in the below code. Could you explain to me.

             

             

            var myDoc = app.activeDocument;
            var myPstyles = myDoc.allParagraphStyles;
            var myAllPStyles = new Array();
            
            for(i=1; i<myPstyles.length; i++)
            {
              var myParaName = myPstyles[i].name;
              myAllPStyles.push(myParaName)
            //var temp = myAllPStyles.toString().split(",")           //Without this line program run successfully
              
              }
            alert(myAllPStyles.toString().replace (/\,/gi, "\r"))
            

             

             

            Could you please explain what is the use of split. Could you please guide me.

             

            Thanks

            Beginner