Skip to main content
August 16, 2013
Question

Find insertionPoints[-1] and change

  • August 16, 2013
  • 1 reply
  • 419 views

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.paragraphs.length;

          while (F--) {

                   

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

                              {

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

                                  }

                              alert ("colon change to semicolon);

                         //     }

                    }

          }

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

Many thanks for the support on this...

This topic has been closed for replies.

1 reply

BEGINNER_X
Brainiac
August 16, 2013

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