Skip to main content
Participant
September 20, 2019
Question

Remove duplicate entries from table of cross references

  • September 20, 2019
  • 3 replies
  • 768 views

I am working in 64bit Windows 7 using InDesign CS6.

 

I am creating a book from multiple files and one of the files is a table of cases drawn from data in the other files.  The entries for the table are created using crossreferences to page numbers. I am trying to find a way to eliminate duplicate page numbers from appearing for a single entry. I have tried search and replace and some simple regex, but since the page number output is actually a cross reference, I can't seem to find the proper way to remove duplicates.

 

For example:

John v Smith................3-12, 3-12, 4-5

Jones v Roberts............2-5, 6-2, 6-2, 7-1

 

In the example the case John v Smith shows up in two locations on page 3-12 and Jones v Roberts appears twice on page 6-2. The table might have several hundred similar duplicates, and I am looking for a way to clear the duplicates with a search and replace or simple script. Does anyone have any ideas on how to remove or hide duplicate cross references?

 

Thanks for any assistance.

    This topic has been closed for replies.

    3 replies

    Peter Kahrel
    Community Expert
    Community Expert
    September 24, 2019

    This one works for me:

    (\d+~=\d+)\K(, \1)+

    (and leave the 'Change to' field empty.)

    Participant
    September 24, 2019
    This worked. Thank you so much for your help.
    Peter Kahrel
    Community Expert
    Community Expert
    September 23, 2019

    That GREP could be better:

    Find what: (\d+-\d+)\K(, \1)+

    Change to: <leave empty>

    This one removes any number of duplicates

    P.

    Peter Kahrel
    Community Expert
    Community Expert
    September 22, 2019

    You'll first need to convert the cross-references to text: select the whole story, then Type > Text Variables > Convert Variable to Text.

    Then you can use a GREP replacement to weed out duplicates:

    Find what: (\d+)-(\d+), \1-\2

    Change to: $1-$2

    This replaces only the second of two identical page references, so if you can have three or more duplicates you need to apply the GREP a few more times.

    P.

    Participant
    September 23, 2019

    Thank you. This is definitely a step in the right direction. However, the "find" string in this post and in your follow up are not returning any results. It is likely that my example was not reflecting the actual text of the duplicates. After using your tip for turning the variables to text I can copy and paste a more accurate piece of text which could hopefully lead to an expresion that will find the correct items: 

     

    AirFacts, Inc. v. de Amezaga 5–21, 5–21, 5–22
    Alagold Corp. v. Freeman 4–32, 4–32

     

    The dash in the page numbers above pastes as ~= in the "find what" line of the GREP tab. I tried replacing the "-" in your expressions with "~=" but still  got no results.

    If I put (\d+)~=(\d+) in the find line, it will find one page number and (\d+)~=(\d+), (\d+)~=(\d+) will find any two consecutive page numbers, I can't figure out how to get the search to only find two identical sequential page numbers. 

    Peter Kahrel
    Community Expert
    Community Expert
    September 24, 2019

    This one works for me:

    (\d+~=\d+)\K(, \1)+

    (and leave the 'Change to' field empty.)