Skip to main content
Participating Frequently
January 11, 2019
Question

GREP for Numbered/Bulleted List

  • January 11, 2019
  • 1 reply
  • 379 views

I want to insert the cursor at the beginning of a Numbered/Bulleted List in InDesign.

The Numbered/Bulleted List has been created in InDesign.

The Numbered/Bulleted List does NOT have a Paragraph Style applied to it.

For example, if I have a list like this:

1.     Adam

2.     Bryan

3.     Chris

4.     David

I want to write a GREP query to place the cursor right before the word Adam.

Find Next should put the cursor right before Bryan, and so on.

This topic has been closed for replies.

1 reply

Inspiring
January 11, 2019

Hi,

     Check with the below code.

app.findGrepPreferences = app.changeGrepPreferences = null; 

app.findGrepPreferences.bulletsAndNumberingListType=ListType.NUMBERED_LIST;

var res = app.activeDocument.findGrep()

alert("RES COUNT :: " + res.length)

for(var pCnt = 0; pCnt <  res.length; pCnt++)

{

var cRes = res[pCnt];
alert("Res.paragraphs.length;" +cRes.paragraphs.length)

  

//for(var npCnt = 0; npCnt < cRes.paragraphs.length; npCnt++)
for(var npCnt = cRes.paragraphs.length - 1; npCnt >= 0; npCnt--)
{
var nPara = cRes.paragraphs[npCnt];
nPara.insertionPoints[0].select()
//app.selection[0].contents = "test"
//------- CODE HERE ----
}

}

app.findGrepPreferences = app.changeGrepPreferences = null;