Generating a two-letter code

I have been trying to generate a two-letter code from a subset of the upper case alphabet.
For the whole alphabet I could have used [:upper:]{2} but because it’s a subset I tried this:

(A|B|D|E|F|G|H|J|L|N|P|Q|R|S|T|U|W|X|Y|Z){2} which seems to be the same approach as your example.

I only get a selection from the end of the list and not from the whole. I didn’t find the GitHub regex info very helpful. A full discussion of this variant of regex might do it.

Meanwhile I’ve done something very crude…
rand1 = “ABDEFGHJLNPQRSTUWXYZ”.slice(random(0,19),1)
rand2 = “ABDEFGHJLNPQRSTUWXYZ”.slice(random(0,19),1)
twoletters = rand1+rand2

Hmm… looks like there might be a bug in the regex library I use. I’ll see if they’ve fixed in a newer version. In the meantime here’s a one-liner you can use in formulas to achieve the desired effect:

%w(A B D E F G H J L N P Q R S T U W X Y Z).sample(2).join('')

I’m going to have to learn Ruby aren’t I?
Anyway I think that makes the whole field this:
’ ’ + random(0,9).to_s + %w(A B D E F G H J L N P Q R S T U W X Y Z).sample(2).join(’’)

I had the same regex issue with (3|4|6|7|9|A|C|D|E|F|G|H|J|K|L|M|N|P|Q|R|T|V|W|X|Y){6} - only the last 5 or 6 characters were used in the output. Thanks for the workaround, works a treat!