Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP pagenumbers to page range when consecutive pages

Return to Member Forum

  • Author
    Posts
    • #64825
      Joram
      Member

      I’m working on a project where i have created 4 lists with cross-references.

      I’ll give an example of a single line in one of the lists:

      Noodles 5, 6, 7, 14, 16, 17, 104, 216, 217

      Noodles = label (no cross-reference)
      The numbers are cross-references.

      I would like to use a GREP that will turn the above line into the following:

      Noodles 5-7, 14, 16-17, 104, 216-217

      So consecutive pages are converted to a page range. Single pages are kept. In between a comma followed by a space ‘, ‘. The last pagenumber or page range does not have a comma followed by a space.

      I’m sure there are other people who have needed this or will need this. Does somebody know a custom GREP that will do this? I’m just not good enough with regular expressions :(

      ————
      Just so i can contribute something at least, here’s a GREP for anyone that just needs a pagerange for first to last instance found (would turn the above example into Noodles 5-217).
      Find what: (\d+),.*(\d+)$
      Change to: $1-$2

    • #103187
      Tiffany Kim
      Member

      Hi Joram, I have the same exact issue now! Trying find consecutive numbers and changing the style to “-“. Did you find a solution for this, by any chance?

    • #103203
      Peter Kahrel
      Participant

      A single GREP isn’t going to do this for you, you need a bit more machinery. Here’s a script that does what you’re after:

      https://www.kahrel.plus.com/indesign/index_update.html

      Peter

Viewing 2 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads