Skip to main content

parse_ranges

Function parse_ranges 

Source
pub fn parse_ranges(
    spec: &str,
    no_merge_adjacent: bool,
) -> Result<Vec<Range>, String>
Expand description

Parse a LIST specification like “1,3-5,7-” into ranges. Each range is 1-based. Returns sorted, merged ranges. When no_merge_adjacent is true, overlapping ranges are still merged but adjacent ranges (e.g., 1-2,3-4) are kept separate. This is needed when --output-delimiter is specified for byte/char mode so the delimiter is inserted between originally separate but adjacent ranges.