(?:X|Y){2} (?# for the first example) (?:X|Y|Z){3} (?# for the second)