GREP: Replacing consecutive numbers with dash

Learn / Forums / General InDesign Topics / GREP: Replacing consecutive numbers with dash

Viewing 2 reply threads
  • Author
    Posts
    • #14338582
      Cristian Radu
      Participant

      Hi. Is there a possibility to replace the consecutive numbers with a dash? Like: 12, 13, 14, 15 -> 12-15.

      Is about pages from an index and I couldn’t find a way to do this from inside the Index panel or with a script.

    • #14339742
      Aaron Troia
      Participant

      Unfortunately not, GREP isn’t smart enough to recognize consecutive numbers like that, but you could do it if you selected the numbers, but you would physically need to select each range of numbers which I’m not really sure would be any quicker.

      Here is an example GREP for that (with text selected)
      Find:(\d+),.+?(\d+)$
      Change: $1–$2
      Search: Selection

      Aaron

    • #14339744
      Cristian Radu
      Participant

      Thanks for your answer. Fortunately I found a script that solved my issue.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>