simplify string of consecutive integers

trying to convert in a possibly consecutive string of integers , comma separated of the form:

chapters = 1,2,3,5,7,8,9,11,12,13,14,15,16,17,18,19,20,21,23

to chapters 1-3,5,7-9,11-21,23

idea is to simplify and group the information from the string.

Sponsor our Newsletter | Privacy Policy | Terms of Service