This seems to be enough of a common occurrence that people need, but in the answers I have found so far, they are in another programming language, do not achieve the full effect that is ready to use, or act in reverse:
- Are there any libraries for parsing “number expressions” like 1,2-9,33- in Java 3
- Regex parse a list of comma separated number ranges, and capture them in individual groups
- Complex algorithm to extract numbers/number range from a string
- Parsing a list of single numbers and number ranges
- .NET Regex expression to parse list of numbers and number ranges
- Convert List of Numbers to String Ranges
- Passing integer lists to python
- Parse numeric sequence into ranges of 20 at the command line
One recommendation was to use Lazy.js, but there is no special function there. I could certainly compose some statements and work through the problem, just like a couple of others have done as well.
I was expecting a ready-made interface that accepts a string, and outputs the expanded list of single integers (as I think that would be easiest for the program to operate on, not sure). Something like "1,3-6,7,12-13"
, or even "1,3-6,7,12-13, 17-"
with 26 pages would produce "1,3,4,5,6,7,12,13,17,18,19,20,21,22,23,24,25,26"
(1-indexed, all inclusive).
That's all of the possibilities I can think of for syntax and capability this far.
Are there any code files, functions, or libraries that are already made and available, implying greater and some testing, that are available in a Linux Shell/CLI tool (similar to seq
), JavaScript, or even Python package format, that I can use out-of-the-box (OOB?) / immediately without additional creative effort required to build this functionality.