Highlighted

Grep question (duplicated lines)

Contributor ,
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

 

 

 

 

Adobe Community Professional
Correct answer by TᴀW | Adobe Community Professional

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

TOPICS
How to

Views

79

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

Grep question (duplicated lines)

Contributor ,
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

 

 

 

 

Adobe Community Professional
Correct answer by TᴀW | Adobe Community Professional

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

TOPICS
How to

Views

80

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
Aug 25, 2020 0
Adobe Community Professional ,
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.

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
Reply
Loading...
Aug 25, 2020 1
Contributor ,
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.

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
Reply
Loading...
Aug 25, 2020 0
SJRiegel LATEST
Adobe Community Professional ,
Aug 29, 2020

Copy link to clipboard

Copied

  • 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.

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
Reply
Loading...
Aug 29, 2020 0
Adobe Community Professional ,
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

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
Reply
Loading...
Aug 25, 2020 0
Contributor ,
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.

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
Reply
Loading...
Aug 25, 2020 0
Contributor ,
Aug 25, 2020

Copy link to clipboard

Copied

$1*$2, $3

 

is a variation to preserve the *

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
Reply
Loading...
Aug 25, 2020 1
Contributor ,
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

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
Reply
Loading...
Aug 26, 2020 0