Skip to main content
selvam214
Inspiring
May 5, 2021
Answered

Grep replace goes wrong near endnote reference

  • May 5, 2021
  • 2 replies
  • 8113 views

Hi,

While replacing the close quotes with GREP to one-by-one, its working fine. But useing replace all, the issue happen occuring, the same in coding also (Para breaking). Is this CC2020 bug or any connection with the endnote?

 

app.selection = NothingEnum.NOTHING;

app.findGrepPreferences = app.changeGrepPreferences = null; app.findChangeGrepOptions.includeFootnotes = true;

app.findChangeGrepOptions.includeHiddenLayers = false; app.findChangeGrepOptions.includeLockedLayersForFind = true; app.findChangeGrepOptions.includeLockedStoriesForFind = true; app.findChangeGrepOptions.includeMasterPages = false;

app.findGrepPreferences.findWhat = "(\\[LSQ\\].+?)~]";

app.changeGrepPreferences.changeTo="$1[RSQ]";

myFoundItems =app.documents.item(0).changeGrep();

 

Kindly guide and share if any alternate. Recorded file is attached for your reference. 

 

Thanks,

Selva

This topic has been closed for replies.
Correct answer FRIdNGE

Your Grep syntax is correct and works for me even if I prefer:

 

app.findGrepPreferences.findWhat = "\\[LSQ\\].+?\\K~]";

app.changeGrepPreferences.changeTo = "[RSQ]";

 

(^/)  The Jedi

2 replies

FRIdNGE
FRIdNGECorrect answer
Inspiring
May 5, 2021

Your Grep syntax is correct and works for me even if I prefer:

 

app.findGrepPreferences.findWhat = "\\[LSQ\\].+?\\K~]";

app.changeGrepPreferences.changeTo = "[RSQ]";

 

(^/)  The Jedi

selvam214
selvam214Author
Inspiring
May 6, 2021

Hi Jedi,

Thanks for this, I'll check and get back you shortly. 

 

 

Thanks,

Selva

Community Expert
May 5, 2021

What exactly do you mean with 'goes wrong near endnote reference'? Where is the endnote reference and what goes wrong with it?

selvam214
selvam214Author
Inspiring
May 6, 2021

Hi Kahrel,

Sorry for the delay,  the below screenshot is useful for better understand. The recorded file is also attached to this blog.

 

Find grep:

 Change All:

 

Thanks,

Selva

FRIdNGE
Inspiring
May 6, 2021

The problem is that . (the dot) doesn't match the endnote marker.  It should not-match only the paragraph mark. That's an InDesign bug that's been around since CS3 and causes a lot of trouble.

But even if it worked, you can't match some text with an endnote (or a footnote, for that matter, same behaviour), and use it in a variable for a replacement: you just lose the note.

Instead, use this query:

Find what: "\\[LSQ\\][^~]]+\\K~]"

Change to: "[RSQ]"

The [^x] notation means 'not x' and can always be used as an alternative for .+?x

As a bonus, it's more efficient!

P.


"The problem is that . (the dot) doesn't match the endnote marker."

 

Peter, no problem with end notes!

 

(^/)