Grep find/replace not working like it used to

Community Beginner ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

I'm trying to figure out if there's been a change with InDesign CC 2021, or if there's something else at play. We have a script that used to take delete a line of text and replace with a space - it is leaving the line in now:

 

app.findGrepPreferences.findWhat = "ALL CONTENT MUST BE AFTER THIS LINE - DO NOT REMOVE";
app.changeGrepPreferences.changeTo = "";
selectedText.changeGrep();
TOPICS
Scripting

Views

89

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , May 17, 2022 May 17, 2022
We have to use InDesign V 16. I just did an update to 16.4.2 and it is working again. Thanks for looking into this!

Likes

Translate

Translate
Adobe Community Professional ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

Hi @Sally5C0E, I tested that code and it worked as expected for me (replaced the findWhat text with nothing). Here's the exact code I tested:

var doc = app.activeDocument,
    selectedText = doc.selection[0];

app.findGrepPreferences.findWhat = "ALL CONTENT MUST BE AFTER THIS LINE - DO NOT REMOVE";
app.changeGrepPreferences.changeTo = "";
selectedText.changeGrep();

Are you getting an error? Have you double-checked the findWhat string does match the document text? Perhaps you could post a sample document?

- Mark

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

Yes, the document text does match - here's a sample text document.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

Thanks @Sally5C0E. I tested by importing your .rtf file and it works as expected (Indesign 17.2.1, MacOS 12.3.1).

 

Could you please make a new document, import .rtf file and test your code? And if it doesn't work with that, please post that indesign file that fails? And your test code? Then we can get to the bottom of it.

- Mark

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

We have to use InDesign V 16. I just did an update to 16.4.2 and it is working again. Thanks for looking into this!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

LATEST

Okay glad it's working. 🙂 Glitches are sometimes fixed by updating.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines