qr[ ^\s* ## from the start of the string, skip whitespace (if any) (?: \d+ - \d+ ) ## then grab (at least one) pair of numbers separated by '-' (?: ## a group \s* , \s* ### a comma, optionally preceded or followed by whitespace \d+ - \d+ ### and another pair of numbers separated by '-' )* ## zero or more times \s*$ ## to the end of string, optionally skipping whitespace if any ]x