Yah! You got there in the end, but the important point is that you probably now understand your code.
One thing about testing. When you test some code, don't just try values which you expect to work, also try a whole bunch of things that should not work and make sure that is actually the case. Try various combinations of invalid characters (even punctuation) and both too many and too few characters.
Finally, although you used [A-Z] in the code, if the actual range of allowed letters is small you could list those instead, e.g. ^[DNST][RTX]/ etc.