1 Reply Latest reply on Aug 16, 2013 5:02 AM by BEGINNER_X

    Find insertionPoints[-1] and change

    indegn5

      HI Forum,

       

      I'm using this to find only the lowercase character starting in bullets list.

       

      And to check the previous line last character for semicolon; if not change it to semicolon.

       

      eg.

       

      • Anchor;

      • substitute:  // here colon (:) has to be changed to semicolon (;)

      • aptitue:  // here colon (:) has to be changed to semicolon (;)

      • Rltitute: // not here....

      • Residue.

       

      now, if the character after bullet start with lowercase, the previous character has to be semicolon

       

       

       

       

      myDoc = app.activeDocument;

      app.findGrepPreferences = null;

      app.findGrepPreferences.findWhat = "^[[:lower:]]";

      app.findGrepPreferences.bulletsAndNumberingListType = ListType.BULLET_LIST;

      mFound = myDoc.findGrep(true);

      l = mFound.length;

      while (l--) {

                F = mFound[l].paragraphs.length;

                while (F--) {

                         

      if(mFound[l].paragraphs[F].insertionPoints[-1].contents[0] == ":")  // check for colon

                                    {

                                        mFound[l].paragraphs[F].insertionPoints[-1].contents[0] = ";" // change to semicolon

                                        }

                                    alert ("colon change to semicolon);

                               //     }

                          }

                }

       

      but mFound[l].paragraphs[F].insertionPoints[-1].contents[0] displays nothing.

       

      Many thanks for the support on this...

        • 1. Re: Find insertionPoints[-1] and change
          BEGINNER_X Level 3

          Hi,

           

          Please use the below code, it may helpful:

           

           

          app.findTextPreferences = app.changeGrepPreferences = null;
          
          app.findGrepPreferences.bulletsAndNumberingListType = ListType.BULLET_LIST;
          
          app.findGrepPreferences.findWhat = "^(\\l.+)(:$)";
          
          app.changeGrepPreferences.changeTo = "$1;"
          
          app.activeDocument.changeGrep();
          

           

          If above code helps for you, please provide helpful or correct answers for me.

           

          Thanks

          Beginner_X