def rangeSplit(rangeStr):
    """Return an array of numbers from a specified set of ranges.

    Given a string such as "1 2 4-6 8" will return [1,2,4,5,6,8].  The numbers
    and ranges can either be space separated or comma separated (but not both).

    Keyword arguments:
    rangeStr -- a string containing ranges such as "1 2 4-6 8"
    """

    result = []
    splitChar = ' '
    if ',' in rangeStr:
        splitChar = ','

    for part in rangeStr.split(splitChar):
        if '-' in part:
            a, b = part.split('-')
            a, b = int(a), int(b)
            result.extend(range(a, b + 1))
        else:
            a = int(part)
            result.append(a)
    return result