I want to check if my students get the RegEx to that Question right:
We want to have a number from 1 to 6 and afterwords a letter from a to d which could be written small or big. So things like 1d, 2A, 4b, ...
The RegEx I want to have from my students should be something like [1-6][a-dA-D]
or [123456][abcdABCD]
or mixtures of these two and all permutations of the second ones.
In my researches I found this answer for the permutations:
^(?:([1-4])(?!.*\1)){4}$
and it works by it's own (as well without the ^$
) but when I combine it with a choices operator (|
) it allows as well repetitions like [111111][a-dA-D]
and that's not what I want to have.
That's what I try out until yet:
[\[]((?:([1-6])(?!.*\1)){6}|[1]\-[6])[\]][\[]((?:([a-dA-D])(?!.*\1)){8}|([a][\-][d][A][\-][D]|[A][\-][D][a][\-][d]))[\]]
Testdata:
[1-6][A-Da-d]
[123456][a-dA-D]
[654321][AaBbCcDd]
[241365][abcdABCD]