Skip to main content
Participant
Apr 15, 2021 2:47 PM UTC
Answered

[ Branched ] Group consecutive numbers

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 is closed to new replies. Start a new post to keep the conversation going.
pixxxelschubser
pixxxelschubserCorrect answer
Community Expert
Apr 17, 2021 8:49 PM UTC

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.

 

 

10 replies

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
Apr 17, 2021 8:49 PM UTC

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.

 

 

Translate
Participant
Apr 19, 2021 7:46 AM UTC

Thanks a lot. This was of real help.

Translate
pixxxelschubser
Community Expert
Community Expert
Apr 17, 2021 5:32 PM UTC

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.

Translate
Participant
Apr 17, 2021 6:49 PM UTC

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.

Translate
Community Expert
Apr 17, 2021 10:45 AM UTC

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

 

 

Translate
Participant
Apr 17, 2021 3:32 PM UTC

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. 

Translate
FRIdNGE
Apr 17, 2021 5:08 PM UTC

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

 

(^/)  The Jedi

Translate
Joely10623436
Community Expert
Community Expert
Apr 16, 2021 7:05 AM UTC

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.

Translate
Participant
Apr 17, 2021 9:53 AM UTC

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.

Translate