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

Grep question (duplicated lines)

Engaged ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

Have an index with duplicated entries:

 

the tempest*230-231, 247, 316
the tempest*370, 390

 

(between the entry and the numbers we may have any delimiter element: *, tab, etc

 

and need to «grep» this to get:

 

the tempest*230-231, 247, 316, 370, 390

 

(the page order is not necessary)

 

thanks

 

 

 

 

TOPICS
How to

Views

357

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

People's Champ , Aug 25, 2020 Aug 25, 2020

It can be done with GREP.

The basic idea is to search for something like this:

^(.+?)\*(.+)\r\1\*(.+)

and replace with

$1 $2, $3

This will work with your exact example with the *. If you're using a different delimiter. replace the \* with [*\t] and whatever else might be the delimiter.

The trick here is to use the \1 to refer to whatever was captured initially.

 

HTH,

Ariel

Votes

Translate

Translate
Community Expert ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

I don't know how to GREP this, but for this to happen in the first place, it must be that there is a difference in the way the second two items have their index entry compared to the first two. (I don't know any other reason that this would happen) I would approch this by going into the index panel and fixing the entries for the second two items to exactly match the first.

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
Engaged ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

We have a book divided into two files.

That is the reason behind two similar entries as some topics are present in both files.

 

With a list of words suggested by the author, we got for the moment this output.

 

Thanks.

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 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

LATEST
  • We have a book divided into two files.

 

You can avoid this sort of duplication in your index by connecting the two files with an InDesign Book file.

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
People's Champ ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

It can be done with GREP.

The basic idea is to search for something like this:

^(.+?)\*(.+)\r\1\*(.+)

and replace with

$1 $2, $3

This will work with your exact example with the *. If you're using a different delimiter. replace the \* with [*\t] and whatever else might be the delimiter.

The trick here is to use the \1 to refer to whatever was captured initially.

 

HTH,

Ariel

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
Engaged ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

the tempest*230-231, 247, 316, 370, 390

YES

 

undeniable, it is magic. your answer is full of elegance and generosity.

thanks.

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
Engaged ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

$1*$2, $3

 

is a variation to preserve the *

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
Engaged ,
Aug 26, 2020 Aug 26, 2020

Copy link to clipboard

Copied

to preserve the consecutive order of numbers:

 

$1*$3, $2

BID*5, 156, 214, 216, 260, 293, 300, 386, 431

 

instead of

 

$1*$2, $3

BID*214, 216, 260, 293, 300, 386, 431, 5, 156

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