#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Help with my table of content


    I have a table of content in InDesign CS5. But I need to modify the content. Alot of them.

    Every two lines that have the same pagenumber (they always follow each other like in the example below) need to switch place. And then be put as a single row with a slash (/) between.


    FROM THIS:

    SP1............................25
    SP2............................26
    MP1B..........................27
    MP1A .........................27
    MP1C..........................28

    TO THIS:

    SP1............................25
    SP2............................26
    MP1A / MP1B..............27
    MP1C..........................28

    Note that the totted line .... is a tab in InDesign.
    Example: SP1\t25

    Is there a way to do this?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,002
    Rep Power
    9398
    The best thing would be a simple script in whatever programming language you like most.

    Otherwise, if you want to apply a regex over and over again until it stops matching, it depends on what features InDesign supports. Try a find with
    Code:
    ^([^.]+)\t+([0-9]+)[\r\n]+([^.]+)\t+\2[^0-9]
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0
    There is actually a grep search function in InDesign.

    Yes, your regex need many applies. But your regex gave me some clues with the backreference function \1 \2 etc - that was actually the function I was looking for =)

    Based on your script I solved it in this way. Searching with InDesign's GREP "search and replace" I can now change my table of content with just one click =) yey! Tnx!

    FIND: ^(.+)\t(\d+)\r^(.+)\t\2
    CHANGE TO: $3/$1\t$2

    Note: In InDesign's "change to" field, the $1 $2 etc is used for backreferences.

IMN logo majestic logo threadwatch logo seochat tools logo