• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP and Cross-Reference Find/Change

Community Beginner ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

Dear all, I'm asking for Your help.

I need to change some formula in a big book that includes cross reference. I've got repeating formula that goes like this:

Details - see page 171
Détails v. page 171
Detalles v. página 171
Dettagli v. pagina 171

The number of page is a cross-reference link which varies depending of product which it connects. My goal is to add another (polish) translation between french and spanish one. So I thought this sentence would work:

Find: (Détails v. page )(~v$)

Change: $1$2\nStronas\$2

Hovewer instead of getting right cross-reference to specific page, it changes page numer to the one, on which the sentence is located. Could You tell me, what I've done wrong?

Kind regards,

Piotr

TOPICS
How to

Views

281

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

Guide , Aug 25, 2023 Aug 25, 2023

Simplically:

 

Capture d’écran 2023-08-25 à 19.37.40.pngCapture d’écran 2023-08-25 à 19.37.56.png

… using this simple Script:

 

var myDoc = app.activeDocument;
// Step 1
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Détails v\\. page ~v\\r";
myFound = myDoc.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) myFound[f].duplicate(LocationOptions.AFTER, myFound[f]);
// Step 2
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(Détails v\\. page) ~v\\r\\K\\1";
app.changeGrepPref
...

Votes

Translate

Translate
Community Expert ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

You can't use GREP variables like that, it works only for literal text. Not for cross-references, footnotes, endnotes, etc.

Votes

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 ,
Aug 27, 2023 Aug 27, 2023

Copy link to clipboard

Copied

LATEST

Thank You!

Votes

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 Expert ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

.

Votes

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
Guide ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

Simplically:

 

Capture d’écran 2023-08-25 à 19.37.40.pngCapture d’écran 2023-08-25 à 19.37.56.png

… using this simple Script:

 

var myDoc = app.activeDocument;
// Step 1
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Détails v\\. page ~v\\r";
myFound = myDoc.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) myFound[f].duplicate(LocationOptions.AFTER, myFound[f]);
// Step 2
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(Détails v\\. page) ~v\\r\\K\\1";
app.changeGrepPreferences.changeTo = "Stronas";
myDoc.changeGrep( );
app.findGrepPreferences = app.changeGrepPreferences = null;

alert("Done [" + F + "]")

 

(^/)  The Jedi

Votes

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 Expert ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

Page = Strona - without "s" at the end - probably should have been "~S" as it's GREP.

 

Votes

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 ,
Aug 27, 2023 Aug 27, 2023

Copy link to clipboard

Copied

Thank You very much! I am very grateful for the work you have done.

 

Votes

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