Skip to main content
Participant
April 15, 2021
Answered

[ Branched ] Group consecutive numbers

  • April 15, 2021
  • 4 replies
  • 1022 views

Hi there. My problem is pretty different. I need to find any range of consecutive numbers and replacing the no between first and last with a dash.

E.g.: Find: 12, 13, 14, 15, 16 etc. and replace with 12-16.

Is this possible? Thanks.



[ topic branched to InDesign forum by moderator ]

[ title added by moderator ]

 

 

This topic has been closed for replies.
Correct answer pixxxelschubser

Search for  groupSequentiellNum.jsx  or  groupSequentiellNum2.jsx  by the German script writer Martin Fischer.

These scripts replace:
Content 1 ........ 1, 2
Contents 2 ........ 4, 5, 6
Contents 3 ........ 7, 8, 9, 10

 

in (variant 1):
Contents 1 ........ 1-2
Contents 2 ........ 4-6
Contents 3 ........ 7-10

 

or in (variant 2):

1, 2, 11, 12, 13, 21, 22, 23, 24, 31-32, 41-43, 51-54  -->  1f., 5, 11ff., 21ff., 31f., 41ff., 51ff.

 

 

4 replies

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
April 17, 2021

Search for  groupSequentiellNum.jsx  or  groupSequentiellNum2.jsx  by the German script writer Martin Fischer.

These scripts replace:
Content 1 ........ 1, 2
Contents 2 ........ 4, 5, 6
Contents 3 ........ 7, 8, 9, 10

 

in (variant 1):
Contents 1 ........ 1-2
Contents 2 ........ 4-6
Contents 3 ........ 7-10

 

or in (variant 2):

1, 2, 11, 12, 13, 21, 22, 23, 24, 31-32, 41-43, 51-54  -->  1f., 5, 11ff., 21ff., 31f., 41ff., 51ff.

 

 

Participant
April 19, 2021

Thanks a lot. This was of real help.

pixxxelschubser
Community Expert
Community Expert
April 17, 2021

Do you need the replacement for parts of the text?
Or for a table of contents? (There are already (free) scripts for this.)
Or ...

 

Please give a more detailed description.

Participant
April 17, 2021

It is about the number of pages generated by the Index. Lots of them are consecutive numbers, such as 760, 761, 762, 763, 764 - and I wish to replace them with 760-764. Thanks. I found a script of Peter Kahrel (Index_update, as I remember), but doesn't work. It just deletes the whole paragraph.

Community Expert
April 17, 2021

I'm not a serial GREPer but I came up with this

 

(\d+), \d.+, (\d+)

 

$1-$2

 

It's very specific, so might not catch all cases.

 

For example on 1,2,3,4,5

 

 

Participant
April 17, 2021

Thanks for your effort, you are almost there, but I need to find only consecutive numbers. Your grep finds all the numbers in a row. 

FRIdNGE
April 17, 2021

You need The Force! (I mean scripting!)  😉

 

(^/)  The Jedi

Joely10623436
Community Expert
Community Expert
April 16, 2021

hi,

with GREP Styles/Find&Replace it should be possible, yes…

https://community.adobe.com/t5/indesign/grep-to-find-a-range-of-numbers/m-p/9357941

 

PS: Please specify your «problem» inside the Titel and Content of your post.

Participant
April 17, 2021

Thank you, but your link leads to a different issue and doesn't get an answer to my question.

P.S. I'll try to edit the title of my post.